[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company b8c38ed 2/3: Make non-prefix and prefix matchin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company b8c38ed 2/3: Make non-prefix and prefix matching highlights more compatible |
Date: |
Sun, 26 Sep 2021 17:57:07 -0400 (EDT) |
branch: externals/company
commit b8c38edccbdffd0a8a76d85956e1c696dd955236
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Make non-prefix and prefix matching highlights more compatible
Resolves #519
---
NEWS.md | 5 +++++
company.el | 16 ++++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 61701e5..7bb4c70 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,11 @@
## Next
+* `company-tooltip-common` highlightings with non-prefix and prefix matching
+ backends are more compatible: if the non-prefix matching backend's
completions
+ all have a common part, and so the current prefix can be expanded with
+ `company-complete-common`, that part is now also highlighted with that face
+ ([#519](https://github.com/company-mode/company-mode/issues/519)).
* `company-yasnippet` respects the `condition` directive in snippets
([#1179](https://github.com/company-mode/company-mode/issues/1179)).
* New user option `company-icon-margin`.
diff --git a/company.el b/company.el
index 9704a73..d055a46 100644
--- a/company.el
+++ b/company.el
@@ -2972,12 +2972,20 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
(pop copy))
(apply 'concat pieces)))
+(defun company--common-or-matches (value)
+ (let ((matches (company-call-backend 'match value)))
+ (when (and matches
+ (= 1 (length matches))
+ (= 0 (caar matches))
+ (> (string-width company-common) (cdar matches)))
+ (setq matches nil))
+ (or matches
+ (and company-common (string-width company-common))
+ 0)))
+
(defun company-fill-propertize (value annotation width selected left right)
(let* ((margin (length left))
- (common (or (company-call-backend 'match value)
- (if company-common
- (string-width company-common)
- 0)))
+ (common (company--common-or-matches value))
(_ (setq value (company-reformat (company--pre-render value))
annotation (and annotation (company--pre-render annotation
t))))
(ann-ralign company-tooltip-align-annotations)