Make sure that point never ends up in an invisible region.

* magit.el (magit-correct-point-after-command): New.
(magit-post-command-hook): New, to collect all post-command activitiy.
(magit-mode): Use it instead of magit-highlight-section.
(magit-section-set-hidden): Don't touch the rear-stickyness.
This commit is contained in:
Marius Vollmer 2009-01-19 00:24:11 +02:00
parent b30faeb310
commit b430adda17

View file

@ -568,8 +568,7 @@ Many Magit faces inherit from this one by default."
(forward-line) (forward-line)
(point))) (point)))
(end (magit-section-end section))) (end (magit-section-end section)))
(put-text-property beg end 'invisible hidden) (put-text-property beg end 'invisible hidden))
(put-text-property beg end 'rear-nonsticky t))
(if (not hidden) (if (not hidden)
(dolist (c (magit-section-children section)) (dolist (c (magit-section-children section))
(magit-section-set-hidden c (magit-section-hidden c))))) (magit-section-set-hidden c (magit-section-hidden c)))))
@ -990,6 +989,16 @@ Many Magit faces inherit from this one by default."
(make-variable-buffer-local 'magit-refresh-args) (make-variable-buffer-local 'magit-refresh-args)
(put 'magit-refresh-args 'permanent-local t) (put 'magit-refresh-args 'permanent-local t)
(defun magit-correct-point-after-command ()
;; Emacs often leaves point in invisible regions. If that happens,
;; move point to the end of that region.
(if (get-text-property (point) 'invisible)
(goto-char (next-single-property-change (point) 'invisible))))
(defun magit-post-command-hook ()
(magit-correct-point-after-command)
(magit-highlight-section))
(defun magit-mode () (defun magit-mode ()
"Review the status of a git repository and act on it. "Review the status of a git repository and act on it.
@ -1001,8 +1010,9 @@ Please see the manual for a complete description of Magit.
(setq major-mode 'magit-mode (setq major-mode 'magit-mode
mode-name "Magit" mode-name "Magit"
mode-line-process "" mode-line-process ""
truncate-lines t) truncate-lines t
(add-hook 'post-command-hook #'magit-highlight-section nil t) line-move-visual nil)
(add-hook 'post-command-hook #'magit-post-command-hook nil t)
(use-local-map magit-mode-map) (use-local-map magit-mode-map)
(run-mode-hooks 'magit-mode-hook)) (run-mode-hooks 'magit-mode-hook))