emacs-diffs
[Top][All Lists]
Advanced

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

scratch/bug-42149-funny-pcm-completion-scores 03c160f 4/4: Fix "first-di


From: João Távora
Subject: scratch/bug-42149-funny-pcm-completion-scores 03c160f 4/4: Fix "first-differente" face in completion-pcm--hilit-commonality
Date: Tue, 29 Dec 2020 08:32:33 -0500 (EST)

branch: scratch/bug-42149-funny-pcm-completion-scores
commit 03c160fb1573107586355e851c111326debfe95a
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Fix "first-differente" face in completion-pcm--hilit-commonality
    
    Fixes: bug#42149
    
    Depending on the position of point in the completion and the
    completion style being used, it may or may not make sense for this
    face to appear immediately after point.  This patch assumes that it
    should appear in the first non-matched character after point, which
    may likely be the next one to type to disambiguate between two or more
    completions.
    
    Suggested by Dario Gjorgjevski <dario.gjorgjevski@gmail.com>.
    
    * lisp/minibuffer.el (completion-pcm--hilit-commonality): Fix
    occasional misplacement of completions-first-differente.
---
 lisp/minibuffer.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index dc37c5f..074d436 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -3332,11 +3332,12 @@ between 0 and 1, and with faces 
`completions-common-part',
            ;; for that extra bit of match (bug#42149).
            (unless (= from match-end)
              (funcall update-score-and-face from match-end))
-           (if (> (length str) pos)
-               (add-face-text-property
-                pos (1+ pos)
-                'completions-first-difference
-                nil str))
+           (cl-loop for p from pos below (length str)
+                    unless (eq (get-text-property p 'face str)
+                               'completions-common-part)
+                    return (add-face-text-property p (1+ p)
+                                                   
'completions-first-difference
+                                                   nil str))
            (unless (zerop (length str))
              (put-text-property
               0 1 'completion-score



reply via email to

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