branch: externals/switchy-window
commit c80a1a9ce06af4cbd2950e35ec62f2effc748253
Author: Le Wang <[email protected]>
Commit: Tassilo Horn <[email protected]>

    Reset window cycle when last command wasn't switchy-window
    
    Previously, the window cycling state was only reset by a timer after
    switchy-window-delay seconds. This meant users had to invoke
    switchy-window quickly to cycle through windows in MRU order.
    
    Now if any other command was invoked between switchy-window calls,
    treat it the same as timer elapsing: update the current window's tick
    (marking it as most recently used) and clear the visited list. This
    makes consecutive switchy-window calls cycle through windows regardless
    of timing, while any intervening command locks in the current window
    and starts a fresh cycle.
    
    Signed-off-by: Le Wang <[email protected]>
---
 switchy-window.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/switchy-window.el b/switchy-window.el
index 15de7fbd96..2d80ce792d 100644
--- a/switchy-window.el
+++ b/switchy-window.el
@@ -146,6 +146,12 @@ timestamp)."
   (unless switchy-window-minor-mode
     (user-error "switchy-window requires `switchy-window-minor-mode' being 
active"))
 
+  ;; Treat intervening command same as timer elapsing: lock in current window
+  (unless (eq last-command 'switchy-window)
+    (setf (alist-get (selected-window) switchy-window--tick-alist)
+          (cl-incf switchy-window--tick-counter))
+    (setq switchy-window--visited-windows nil))
+
   ;; Remove dead windows.
   (setq switchy-window--tick-alist (seq-filter
                                     (lambda (e)

Reply via email to