You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(defunexec/save-cursor-position-and-revert-hunk (orig-fun&restargs)
"Advice to remember the cursor position and restore it after reverting a hunk."
(let ((line (line-number-at-pos))
(column (current-column)))
(apply orig-fun args)
(goto-char (point-min))
(forward-line (1- line))
(move-to-column column)))
(advice-add'diff-hl-revert-hunk:around#'exec/save-cursor-position-and-revert-hunk)
Do you mean specifically the scenario when point is inside the hunk? Why do we stay on the same column, though? There seems to be no guarantee that the text under point does not change, or itself move left or right.
When happens currently, is the region is replaced wholesale and point is moved out because the region's text can (and often does) change a lot.
The advice you posted should indeed work, but I wonder if it'll make sense in more cases that it will get things more confusing (e.g. when the hunk was a long addition, so the revert removes it all, but point will jump the corresponding number of lines down).
Hello, thanks for you diff-hl project, it helps me a lot.
When I edited a file, and want to revert to by
diff-hl-revert-hunk
, after revert, the cursor will moved.I think cursor should be stick to same line and same column after
diff-hl-revert-hunk
.What do you think? Thank you.
The text was updated successfully, but these errors were encountered: