Keep point where it was across a refresh.
* magit.el: Don't move point in refresh functions. (magit-refresh): Try to keep point where it was. (magit-run*): Call magit-refresh outside of the save-excursion so that it can move point.
This commit is contained in:
parent
9214dccd6f
commit
f34fee9759
1 changed files with 68 additions and 60 deletions
50
magit.el
50
magit.el
|
@ -123,6 +123,7 @@ Many Magit faces inherit from this one by default."
|
|||
;;; Utilities
|
||||
|
||||
(defun magit-goto-line (line)
|
||||
;; Like goto-line but doesn't set the mark.
|
||||
(save-restriction
|
||||
(widen)
|
||||
(goto-char 1)
|
||||
|
@ -688,10 +689,11 @@ Many Magit faces inherit from this one by default."
|
|||
(t
|
||||
(setq successp
|
||||
(equal (apply 'call-process cmd nil buf nil args) 0))
|
||||
(magit-set-mode-line-process nil)
|
||||
(when (not norefresh)
|
||||
(magit-set-mode-line-process nil))))
|
||||
(when (and (not nowait)
|
||||
(not norefresh))
|
||||
(magit-revert-buffers)
|
||||
(magit-refresh magit-process-client-buffer)))))
|
||||
(magit-refresh magit-process-client-buffer))
|
||||
(or successp
|
||||
noerror
|
||||
(error "Git failed."))
|
||||
|
@ -879,9 +881,27 @@ Please see the manual for a complete description of Magit.
|
|||
(defun magit-refresh (&optional buffer)
|
||||
(interactive)
|
||||
(with-current-buffer (or buffer (current-buffer))
|
||||
(let* ((old-line (line-number-at-pos))
|
||||
(old-section (magit-current-section))
|
||||
(old-path (and old-section
|
||||
(magit-section-path (magit-current-section))))
|
||||
(section-line (and old-section
|
||||
(count-lines
|
||||
(magit-section-beginning old-section)
|
||||
(point)))))
|
||||
(if magit-refresh-function
|
||||
(apply magit-refresh-function
|
||||
magit-refresh-args))))
|
||||
magit-refresh-args))
|
||||
(magit-refresh-marked-commits-in-buffer)
|
||||
(let ((s (and old-path (magit-find-section old-path magit-top-section))))
|
||||
(cond (s
|
||||
(goto-char (magit-section-beginning s))
|
||||
(forward-line section-line))
|
||||
(t
|
||||
(magit-goto-line old-line)))
|
||||
(dolist (w (get-buffer-window-list (current-buffer)))
|
||||
(set-window-point w (point)))
|
||||
(magit-highlight-section)))))
|
||||
|
||||
(defun magit-refresh-all ()
|
||||
(interactive)
|
||||
|
@ -1102,8 +1122,7 @@ Please see the manual for a complete description of Magit.
|
|||
(magit-create-buffer-sections
|
||||
(magit-insert-section 'commitbuf nil
|
||||
'magit-wash-commit nil
|
||||
"git" "log" "--max-count=1" "--cc" "-p" commit))
|
||||
(goto-char (point-min)))
|
||||
"git" "log" "--max-count=1" "--cc" "-p" commit)))
|
||||
|
||||
(defun magit-show-commit (commit &optional scroll)
|
||||
(let ((dir default-directory)
|
||||
|
@ -1168,7 +1187,6 @@ Please see the manual for a complete description of Magit.
|
|||
;;; Status
|
||||
|
||||
(defun magit-refresh-status ()
|
||||
(let ((old-line (line-number-at-pos)))
|
||||
(magit-create-buffer-sections
|
||||
(magit-with-section 'status nil
|
||||
(let* ((branch (magit-get-current-branch))
|
||||
|
@ -1205,12 +1223,7 @@ Please see the manual for a complete description of Magit.
|
|||
(if staged
|
||||
(magit-insert-staged-changes)))
|
||||
(when remote
|
||||
(magit-insert-unpushed-commits remote branch)))))
|
||||
(magit-goto-line old-line)
|
||||
(when (bobp)
|
||||
(magit-goto-section '(unstaged)))
|
||||
(magit-highlight-section)
|
||||
(magit-refresh-marked-commits-in-buffer)))
|
||||
(magit-insert-unpushed-commits remote branch))))))
|
||||
|
||||
(defun magit-status (dir)
|
||||
(interactive (list (magit-read-top-dir current-prefix-arg)))
|
||||
|
@ -1731,9 +1744,7 @@ Please see the manual for a complete description of Magit.
|
|||
(magit-rev-range-describe range "Commits")
|
||||
'magit-wash-log nil
|
||||
"git" "log" "--graph" "--max-count=10000"
|
||||
"--pretty=oneline" args))
|
||||
(magit-refresh-marked-commits-in-buffer)
|
||||
(goto-char (point-min)))
|
||||
"--pretty=oneline" args)))
|
||||
|
||||
(defun magit-log (range)
|
||||
(interactive (list (magit-read-rev-range "Log" (magit-get-current-branch))))
|
||||
|
@ -1756,9 +1767,7 @@ Please see the manual for a complete description of Magit.
|
|||
'magit-wash-log nil
|
||||
"git" "log" "--walk-reflogs"
|
||||
"--max-count=10000"
|
||||
"--pretty=oneline" args))
|
||||
(magit-refresh-marked-commits-in-buffer)
|
||||
(goto-char (point-min)))
|
||||
"--pretty=oneline" args)))
|
||||
|
||||
(defun magit-reflog (head)
|
||||
(interactive (list (magit-read-rev "Reflog of" "HEAD")))
|
||||
|
@ -1780,8 +1789,7 @@ Please see the manual for a complete description of Magit.
|
|||
(magit-insert-section 'diffbuf
|
||||
(magit-rev-range-describe range "Changes")
|
||||
'magit-wash-diffs nil
|
||||
"git" "diff" args))
|
||||
(goto-char (point-min)))
|
||||
"git" "diff" args)))
|
||||
|
||||
(defun magit-diff (range)
|
||||
(interactive (list (magit-read-rev-range "Diff")))
|
||||
|
|
Loading…
Reference in a new issue