[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/icomplete-vertical-mode-improvements 00c0648 2/2: Don't break ic
From: |
João Távora |
Subject: |
scratch/icomplete-vertical-mode-improvements 00c0648 2/2: Don't break icomplete-vertical-mode scrolling when moving non-destructively |
Date: |
Wed, 26 May 2021 10:52:21 -0400 (EDT) |
branch: scratch/icomplete-vertical-mode-improvements
commit 00c0648dc00475ed9666dbe2e03f6a1d177a2140
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Don't break icomplete-vertical-mode scrolling when moving non-destructively
* lisp/icomplete.el (icomplete--render-vertical): Rework.
---
lisp/icomplete.el | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index abb13e5..2575b3c 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -721,13 +721,15 @@ Return a list of (COMP PREFIX SUFFIX)."
(cl-defun icomplete--render-vertical (comps md)
;; This is loopapalooza
;;
- ;; First, attempt to keep selection stable.
+ ;; First, attempt to keep selection stable. Do this only if the
+ ;; selection didn't change but the candidates did.
(when (and icomplete--last-selected
+ (not (eq (cdr icomplete--last-selected) (buffer-modified-tick)))
(null icomplete-rotate))
(cl-loop
with preds
for (comp . rest) on comps
- when (equal comp icomplete--last-selected)
+ when (equal comp (car icomplete--last-selected))
do
(setq icomplete--comp-predecessors preds
comps (cons comp rest))
@@ -760,15 +762,16 @@ Return a list of (COMP PREFIX SUFFIX)."
(setq neighbour (pop succs)) into after
while neighbour
finally
+ (setq icomplete--last-selected
+ (cons (propertize (car comps) 'face
+ 'icomplete-selected-match)
+ (buffer-modified-tick)))
;; Now figure out spacing and layout
;;
(cl-loop
with torender
= (nconc before
- (list
- (setq icomplete--last-selected
- (propertize (car comps) 'face
- 'icomplete-selected-match)))
+ (list (car icomplete--last-selected))
after)
with triplets = (icomplete--affixate md torender)
initially (when (eq triplets torender)