emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ace-window 138a80c 83/92: ace-window.el (aw--lead-overl


From: Stefan Monnier
Subject: [elpa] externals/ace-window 138a80c 83/92: ace-window.el (aw--lead-overlay): Fix double recenter problem
Date: Wed, 17 Mar 2021 18:39:27 -0400 (EDT)

branch: externals/ace-window
commit 138a80cbc4e9ed17d3a085a3687f5223a142a9a3
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    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
---
 ace-window.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/ace-window.el b/ace-window.el
index 55d1ef7..9b61ff3 100644
--- a/ace-window.el
+++ b/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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]