[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 477799b362 18/30: Make suffix matching use "pro
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 477799b362 18/30: Make suffix matching use "proper suffix" logic by default |
Date: |
Sat, 13 Jul 2024 00:57:51 -0400 (EDT) |
branch: externals/company
commit 477799b36210ee27ca8501b6d47637db40ea0a55
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
Make suffix matching use "proper suffix" logic by default
And add popup highlighting for success (when completion will replace it).
---
company.el | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/company.el b/company.el
index 99758ab7e5..f35fb96131 100644
--- a/company.el
+++ b/company.el
@@ -2443,13 +2443,25 @@ For more details see `company-insertion-on-trigger' and
(defsubst company-keep (command)
(and (symbolp command) (get command 'company-keep)))
+(defun company--proper-suffix-p (candidate)
+ (and
+ (>= (length candidate)
+ (+ (length company-prefix)
+ (length company-suffix)))
+ (string-suffix-p company-suffix candidate
+ (company-call-backend 'ignore-case))))
+
(defun company--boundaries (&optional candidate)
(or
(company-call-backend 'adjust-boundaries
(or candidate
(nth (or company-selection 0) company-candidates))
company-prefix company-suffix)
- (cons company-prefix company-suffix)))
+ (and
+ ;; Default to replacing the suffix only if the completion ends with it.
+ (company--proper-suffix-p candidate)
+ (cons company-prefix company-suffix))
+ (cons company-prefix "")))
(defun company--active-p ()
company-candidates)
@@ -3487,7 +3499,7 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(pop copy))
(apply 'concat pieces)))
-(defun company--common-or-matches (value)
+(defun company--common-or-matches (value &optional suffix)
(let ((matches (company-call-backend 'match value)))
(when (and matches
company-common
@@ -3499,7 +3511,13 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(when (integerp matches)
(setq matches `((0 . ,matches))))
(or matches
- (and company-common `((0 . ,(length company-common))))
+ (and company-common `((0 . ,(length company-common))
+ ,@(list
+ (cons
+ (- (length value)
+ (length (or suffix
+ (cdr (company--boundaries
value)))))
+ (length value)))))
nil)))
(defun company-fill-propertize (value annotation width selected left right)
@@ -4221,7 +4239,7 @@ Delay is determined by `company-tooltip-idle-delay'."
(company-common (and company-common
(string-prefix-p prefix company-common)
company-common))
- (common (company--common-or-matches completion)))
+ (common (company--common-or-matches completion suffix)))
(setq completion (copy-sequence (company--pre-render completion)))
(add-face-text-property 0 (length completion) 'company-preview
nil completion)
- [elpa] externals/company 01e82364bf 23/30: company-post-command: Refresh more often, (continued)
- [elpa] externals/company 01e82364bf 23/30: company-post-command: Refresh more often, ELPA Syncer, 2024/07/13
- [elpa] externals/company 78ed92db96 14/30: Fix "Attempt to modify read-only object", ELPA Syncer, 2024/07/13
- [elpa] externals/company ff6107bde3 04/30: company-inhibit-inside-symbols: New option, ELPA Syncer, 2024/07/13
- [elpa] externals/company 426e1830ff 06/30: company--unique-match-p: Also include suffix, ELPA Syncer, 2024/07/13
- [elpa] externals/company d7e77b9673 01/30: #1106 #340 Complete inside symbols, ELPA Syncer, 2024/07/13
- [elpa] externals/company 7ed2baeedd 05/30: Merge branch 'master' into completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company ebe5244443 07/30: Merge branch 'master' into completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company 10fcb21d46 09/30: Remove suffix after completion by company-dabbrev-code too, ELPA Syncer, 2024/07/13
- [elpa] externals/company 2fefdc7ce3 02/30: Fix test failures, ELPA Syncer, 2024/07/13
- [elpa] externals/company 436b0d6247 10/30: New backend command `adjust-boundaries`, ELPA Syncer, 2024/07/13
- [elpa] externals/company 477799b362 18/30: Make suffix matching use "proper suffix" logic by default,
ELPA Syncer <=
- [elpa] externals/company a011dbd892 27/30: Update company-files tests, ELPA Syncer, 2024/07/13
- [elpa] externals/company 277640481a 19/30: Render the "preview" overlay over the matching suffix text, ELPA Syncer, 2024/07/13
- [elpa] externals/company 54b0148ce4 16/30: Fix bytecomp warnings, ELPA Syncer, 2024/07/13
- [elpa] externals/company d4e01ed948 21/30: #1474 change the reference in NEWS, ELPA Syncer, 2024/07/13
- [elpa] externals/company 31f7ad52e4 30/30: Merge pull request #1474 from company-mode/completion_inside_symbol, ELPA Syncer, 2024/07/13
- [elpa] externals/company a253fa5505 25/30: company-files--prefix: Capture suffix as well, ELPA Syncer, 2024/07/13
- [elpa] externals/company bbe0bc031a 13/30: company--multi-backend-adapter: Support suffix and `adjust-boundaries`, ELPA Syncer, 2024/07/13
- [elpa] externals/company c8a06ff3bf 11/30: Support completion styles in company-etags too, ELPA Syncer, 2024/07/13
- [elpa] externals/company a986091380 20/30: Fix test failures, ELPA Syncer, 2024/07/13
- [elpa] externals/company 0503adea94 22/30: company-dabbrev: Also support completion inside a word, ELPA Syncer, 2024/07/13