Browse files

Move to the right column when visiting hunks

Unlike regular diff-mode, Magit loses the column when visiting hunks,
which is very annoying. So compute the destination column and move point
there in the destination buffer.
  • Loading branch information...
rfrancoise committed Dec 9, 2012
1 parent 9baa700 commit 0db5d42bd7bf0dc706cc78d151285e6ed74ce625
Showing with 5 additions and 2 deletions.
  1. +5 −2 magit.el
@@ -5469,14 +5469,17 @@ With a prefix argument, visit in other window."
(let ((file (magit-diff-item-file (magit-hunk-item-diff item)))
- (line (magit-hunk-item-target-line item)))
+ (line (magit-hunk-item-target-line item))
+ (column (current-column)))
(if (not (file-exists-p file))
(error "Can't visit deleted file: %s" file))
(if other-window 'find-file-other-window 'find-file)
(goto-char (point-min))
- (forward-line (1- line))))))
+ (forward-line (1- line))
+ (when (> column 0)
+ (move-to-column (1- column)))))))
(defun magit-visit-item (&optional other-window)
"Visit current item.

0 comments on commit 0db5d42

Please sign in to comment.