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

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

[elpa] externals/company e04c0ce 1/2: company-preview-show-at-point: Beh


From: ELPA Syncer
Subject: [elpa] externals/company e04c0ce 1/2: company-preview-show-at-point: Behave better with non-prefix matching
Date: Sun, 26 Sep 2021 19:57:06 -0400 (EDT)

branch: externals/company
commit e04c0ce0a50c1995a1877d14ac0d5c907e2efe9a
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    company-preview-show-at-point: Behave better with non-prefix matching
    
    Avoid truncation when the common part does not match the prefix.
    
    Mentioned in #519.
---
 company.el | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/company.el b/company.el
index d055a46..80f69b2 100644
--- a/company.el
+++ b/company.el
@@ -3608,11 +3608,16 @@ Delay is determined by `company-tooltip-idle-delay'."
 (defun company-preview-show-at-point (pos completion)
   (company-preview-hide)
 
-  (setq completion (copy-sequence (company--pre-render completion)))
-  (add-face-text-property 0 (length completion) 'company-preview
-                          nil completion)
-  (add-face-text-property 0 (length company-common) 'company-preview-common
-                          nil completion)
+  (let ((company-common (and company-common
+                             (string-prefix-p company-prefix company-common)
+                             company-common) ))
+    (setq completion (copy-sequence (company--pre-render completion)))
+    (add-face-text-property 0 (length completion) 'company-preview
+                            nil completion)
+
+    ;; TODO: Add support for the `match' backend command.
+    (add-face-text-property 0 (length company-common) 'company-preview-common
+                            nil completion)
 
     ;; Add search string
     (and (string-match (funcall company-search-regexp-function
@@ -3622,7 +3627,9 @@ Delay is determined by `company-tooltip-idle-delay'."
            (add-face-text-property mbeg mend 'company-preview-search
                                    nil completion)))
 
-    (setq completion (company-strip-prefix completion))
+    (setq completion (if company-common
+                         (company-strip-prefix completion)
+                       completion))
 
     (and (equal pos (point))
          (not (equal completion ""))
@@ -3645,7 +3652,7 @@ Delay is determined by `company-tooltip-idle-delay'."
       (let ((ov company-preview-overlay))
         (overlay-put ov (if ptf-workaround 'display 'after-string)
                      completion)
-        (overlay-put ov 'window (selected-window)))))
+        (overlay-put ov 'window (selected-window))))))
 
 (defun company-preview-hide ()
   (when company-preview-overlay



reply via email to

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