ace-window.el (aw--lead-overlay): Fix double recenter problem

* ace-window.el (aw--done): Add logic for restoring old window points.
(aw--face-rel-height): Should return 1 for :height 1.0.

When the face height is e.g. 3, we do a recenter to make sure it's
visible. But that shifts the point out of window, which results in another recenter.
After the second recenter the point is visible, but the overlay isn't.

Fixes #176
old-master
Oleh Krehel 7 years ago
parent ab0db6a2c3
commit 138a80cbc4
  1. 20
      ace-window.el

@ -273,6 +273,10 @@ Modify them back eventually.")
"List of (window . hscroll-columns) items, each listing a window whose
horizontal scroll will be restored upon ace-window action completion.")
(defvar aw--windows-points nil
"List of (window . point) items. The point position had to be
moved in order to display the overlay.")
(defun aw--done ()
"Clean up mode line and overlays."
;; mode line
@ -286,8 +290,12 @@ Modify them back eventually.")
(when (string= (buffer-string) " ")
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))))))
(setq aw-empty-buffers-list nil)
(aw--restore-windows-hscroll)
(setq aw-empty-buffers-list nil))
(let (c)
(while (setq c (pop aw--windows-points))
(with-selected-window (car c)
(goto-char (cdr c))))))
(defun aw--restore-windows-hscroll ()
"Restore horizontal scroll of windows from `aw--windows-hscroll' list."
@ -363,8 +371,9 @@ LEAF is (PT . WND)."
(prev nil)
(vertical-pos (if (eq aw-char-position 'left) -1 0))
(horizontal-pos (if (zerop (window-hscroll)) 0 (1+ (window-hscroll))))
(old-pt (point))
(pt
(save-excursion
(progn
;; If leading-char is to be displayed at the top-left, move
;; to the first visible line in the window, otherwise, move
;; to the last visible line.
@ -381,6 +390,11 @@ LEAF is (PT . WND)."
(recenter vertical-pos)
(point)))
(ol (make-overlay pt (1+ pt) (window-buffer wnd))))
(if (= (aw--face-rel-height) 1)
(goto-char old-pt)
(when (/= pt old-pt)
(goto-char (+ pt 1))
(push (cons wnd old-pt) aw--windows-points)))
(overlay-put ol 'display (aw--overlay-str wnd pt path))
(overlay-put ol 'face 'aw-leading-char-face)
(overlay-put ol 'window wnd)
@ -837,7 +851,7 @@ Modify `aw-fair-aspect-ratio' to tweak behavior."
((eq h 'unspecified)
1)
((floatp h)
(1+ (floor h)))
(max (floor h) 1))
((integerp h)
1)
(t

Loading…
Cancel
Save