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

Loading…
Cancel
Save