Skip to content

fix the weird line shift after staging file#1371

Closed
liangkarl wants to merge 0 commit intojonas:masterfrom
liangkarl:line_shift_bug
Closed

fix the weird line shift after staging file#1371
liangkarl wants to merge 0 commit intojonas:masterfrom
liangkarl:line_shift_bug

Conversation

@liangkarl
Copy link
Copy Markdown

@liangkarl liangkarl commented Mar 22, 2025

There is a bug with an incorrect line shift. After entering the stage window and staging any file in the main view, you will find a weird line shift, jumping two lines instead of one.

Reproduce steps

  1. touch a b c d
  2. Open tig and enter "Untracked changes"
  3. Press u to stage any file
  4. You could find the line shifting two instead of one.

src/status.c Outdated
return false;
}

if (line->type != LINE_STAT_STAGED && !no_files_staged)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch but wrong solution, this code is needed in the plain status view. However we should not call it in the "Untracked only" status view:

diff --git a/src/status.c b/src/status.c
index 1e79cb82..82a52bec 100644
--- a/src/status.c
+++ b/src/status.c
@@ -652,7 +652,7 @@ status_update(struct view *view)
                return false;
        }

-       if (line->type != LINE_STAT_STAGED && !no_files_staged)
+       if (!show_untracked_only && line->type != LINE_STAT_STAGED && !no_files_staged)
                view->pos.lineno += 1;

        return true;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Thanks for the explanation! : )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do I need to close the PR, or will you close it after committing the changes?

Copy link
Copy Markdown
Collaborator

@koutcher koutcher Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave it open, I'll use it to commit the changes.

koutcher added a commit that referenced this pull request Apr 11, 2025
Original-patch-by: Karl Liang <liang.karl@outlook.com>
@koutcher koutcher closed this Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants