Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff-hl-show-hunk-next tell "There is no next change", but, diff-hl-next-hunk can jump to it. #175

Open
zw963 opened this issue Nov 3, 2021 · 3 comments

Comments

@zw963
Copy link

zw963 commented Nov 3, 2021

I don't know which command is work correct, but if one work correct, i guess another one must be incorrect.

Following is a reproduce:

  1. we assume a Gemfile exists some different.
    image

  2. restart emacs as daemon, and open Gemfile use emacs client

  3. switch to beginning of buffer.

  4. Both C-x v ] and C-x v } can jump to the difference as expect.

  5. run git add Gemfie on command line

  6. C-x v ] can jump, but C-x v } not jump, message: There is no next change
    Question 1: which command is correct?

When i set (setq diff-hl-show-staged-changes nil), not jump is correct, right?

  1. run git reset on command line

  2. behavior same as 6, in this case, jump is correct, right?

I assume diff-hl check the git operation from command line is not so easy, e.g. when i do staging from command line successful, i still see the fringe indicate exists diff on this line.

image

image

though, that maybe another issue,

but, this issue focus on above two command should not behavior different in this case.

Thank you.

@dgutov
Copy link
Owner

dgutov commented Nov 7, 2021

Hi!

I can reproduce this, I think. Though I think the actual scenario is a little more complicated: you first have to have tested with (setq diff-hl-show-staged-changes nil), and then with (setq diff-hl-show-staged-changes t) again.

Does the below help, or are we talking about different scenarios?

diff --git a/diff-hl-show-hunk.el b/diff-hl-show-hunk.el
index 00f6d92..42c3523 100644
--- a/diff-hl-show-hunk.el
+++ b/diff-hl-show-hunk.el
@@ -342,7 +342,9 @@ end of the OVERLAY, so posframe/inline is placed below the hunk."
 (defun diff-hl-show-hunk-next ()
   "Go to next hunk/change and show it."
   (interactive)
-  (let* ((point (if diff-hl-show-hunk--original-overlay
+  (let* ((point (if (and
+                     diff-hl-show-hunk--original-buffer
+                     diff-hl-show-hunk--original-overlay)
                     (overlay-start diff-hl-show-hunk--original-overlay)
                   nil))
          (next-overlay (diff-hl-show-hunk--next-hunk nil point)))

If it does not, or if the fix doesn't seem enough for you, what if after step 5 you refresh the highlightings with M-x revert-buffer? Does the next step look consistent to you?

@zw963
Copy link
Author

zw963 commented Nov 7, 2021

Does the below help, or are we talking about different scenarios?

Yes, i consider behavior is almost same for now, though, there still exists some issue, will describe later.

After run git add diff-hl.el successful, and jump to beginning-of-buffer.

  1. when i run C-x v ], cursor jump to line 181, like this.
    image

Or

  1. when i run C-x v }, cursor jump to line 191, and we can see "no next hunk` on minibuffer.
    image

So, i thought we have two issue:

  1. C-x v ] is jump to line 181, C-x v } jump to line 191, they use different logic i guess, that not good. (this is consider as a new issue) ?

  2. C-x v ] can be jump continuously with ] when enable repeat mode, C-x v } do it same way for now, but, with a "no next hunk" error message, but can jump continuously anyway.

@zw963
Copy link
Author

zw963 commented Dec 21, 2021

This issue still exists, simply to say, current git status is modifed status:

## master
 M deploy_start.sh

C+v] can jump to next hunk, but (diff-hl-show-hunk-next) can not.

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

No branches or pull requests

2 participants