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

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

[elpa] externals/company bc52a6136e 17/30: Strip the matching suffix in


From: ELPA Syncer
Subject: [elpa] externals/company bc52a6136e 17/30: Strip the matching suffix in preview too
Date: Sat, 13 Jul 2024 00:57:51 -0400 (EDT)

branch: externals/company
commit bc52a6136e5065737c5bd69a6068a066439dd3cd
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    Strip the matching suffix in preview too
    
    #340
---
 company.el | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/company.el b/company.el
index 65b3ed84a7..99758ab7e5 100644
--- a/company.el
+++ b/company.el
@@ -4217,6 +4217,7 @@ Delay is determined by `company-tooltip-idle-delay'."
 
   (let* ((boundaries (company--boundaries completion))
          (prefix (car boundaries))
+         (suffix (cdr boundaries))
          (company-common (and company-common
                               (string-prefix-p prefix company-common)
                               company-common))
@@ -4243,6 +4244,11 @@ Delay is determined by `company-tooltip-idle-delay'."
                          (company-strip-prefix completion prefix)
                        completion))
 
+    (setq completion (if (string-suffix-p suffix completion)
+                         (substring completion 0 (- (length completion)
+                                                    (length suffix)))
+                       completion))
+
     (when (string-prefix-p "\n" completion)
       (setq completion (concat (propertize " " 'face 'company-preview) "\n"
                                (substring completion 1))))
@@ -4303,14 +4309,18 @@ Delay is determined by `company-tooltip-idle-delay'."
     (company-preview-frontend command)))
 
 (defun company--show-inline-p ()
-  (let ((prefix (car (company--boundaries (car company-candidates)))))
+  (let* ((boundaries (company--boundaries (car company-candidates)))
+         (prefix (car boundaries))
+         (suffix (cdr boundaries))
+         (ignore-case (company-call-backend 'ignore-case))
+         (candidate (car company-candidates)))
     (and (not (cdr company-candidates))
-         (string-empty-p company-suffix)
          company-common
          (not (eq t (compare-strings prefix nil nil
-                                     (car company-candidates) nil nil
+                                     candidate nil nil
                                      t)))
-         (or (eq (company-call-backend 'ignore-case) 'keep-prefix)
+         (string-suffix-p suffix candidate ignore-case)
+         (or (eq ignore-case 'keep-prefix)
              (string-prefix-p prefix company-common)))))
 
 (defun company-tooltip-visible-p ()



reply via email to

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