[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4d8ac8c 17/66: Support multiple-width chars in annotations
From: |
Dmitry Gutov |
Subject: |
[elpa] master 4d8ac8c 17/66: Support multiple-width chars in annotations |
Date: |
Tue, 13 Jan 2015 02:44:48 +0000 |
branch: master
commit 4d8ac8c02cbabbcfda0cba00628f446877417795
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Support multiple-width chars in annotations
Fixes #230
---
company-tests.el | 16 ++++++++++++++--
company.el | 12 +++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/company-tests.el b/company-tests.el
index 0663c71..26e98e2 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -567,8 +567,8 @@
"avatar"))
(company-candidates-length 2)
(company-backend 'ignore))
- (should (equal '(" avalis‗e "
- " avatar ")
+ (should (equal '(" avalis‗e "
+ " avatar ")
(company--create-lines 0 999)))))
(ert-deftest company-create-lines-handles-multiple-width ()
@@ -581,6 +581,18 @@
" 蛙abc ")
(company--create-lines 0 999)))))
+(ert-deftest company-create-lines-handles-multiple-width-in-annotation ()
+ (let* (company-show-numbers
+ (alist '(("a" . " ︸") ("b" . " ︸︸")))
+ (company-candidates (mapcar #'car alist))
+ (company-candidates-length 2)
+ (company-backend (lambda (c &optional a)
+ (when (eq c 'annotation)
+ (assoc-default a alist)))))
+ (should (equal '(" a ︸ "
+ " b ︸︸ ")
+ (company--create-lines 0 999)))))
+
(ert-deftest company-column-with-composition ()
:tags '(interactive)
(with-temp-buffer
diff --git a/company.el b/company.el
index 10e1807..a44f150 100644
--- a/company.el
+++ b/company.el
@@ -2103,7 +2103,6 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(string-width company-common)
0)))
(ann-ralign company-tooltip-align-annotations)
- (value (company--clean-string value))
(ann-truncate (< width
(+ (length value) (length annotation)
(if ann-ralign 1 0))))
@@ -2324,11 +2323,14 @@ If SHOW-VERSION is non-nil, show the version in the
echo area."
(dotimes (_ len)
(let* ((value (pop lines-copy))
(annotation (company-call-backend 'annotation value)))
- (when (and annotation company-tooltip-align-annotations)
- ;; `lisp-completion-at-point' adds a space.
- (setq annotation (comment-string-strip annotation t nil)))
+ (setq value (company--clean-string value))
+ (when annotation
+ (when company-tooltip-align-annotations
+ ;; `lisp-completion-at-point' adds a space.
+ (setq annotation (comment-string-strip annotation t nil)))
+ (setq annotation (company--clean-string annotation)))
(push (cons value annotation) items)
- (setq width (max (+ (string-width value)
+ (setq width (max (+ (length value)
(if (and annotation
company-tooltip-align-annotations)
(1+ (length annotation))
(length annotation)))
- [elpa] master b6da724 03/66: Clean up a little, (continued)
- [elpa] master b6da724 03/66: Clean up a little, Dmitry Gutov, 2015/01/12
- [elpa] master 67ead1a 06/66: Bump the year, Dmitry Gutov, 2015/01/12
- [elpa] master eb03746 09/66: company-cmake--unexpand-candidate: Remove extra underscore, Dmitry Gutov, 2015/01/12
- [elpa] master 28f8dc6 11/66: Update NEWS, Dmitry Gutov, 2015/01/12
- [elpa] master e5627dd 12/66: company-etags-file-table: Check that TAGS is not a directory, Dmitry Gutov, 2015/01/12
- [elpa] master e66f2c3 13/66: company-bbdb: Use the whole line content after `: ' as prefix, Dmitry Gutov, 2015/01/12
- [elpa] master 79d4b0d 10/66: company-cmake: Support G77/Fortran distinction, Dmitry Gutov, 2015/01/12
- [elpa] master 4375685 14/66: company-complete-number: Handle keypad events, Dmitry Gutov, 2015/01/12
- [elpa] master e692260 15/66: Show numbers in tooltip irrespective of scrolling, Dmitry Gutov, 2015/01/12
- [elpa] master c97666c 18/66: company-files--complete: Ignore case on appropriate systems, Dmitry Gutov, 2015/01/12
- [elpa] master 4d8ac8c 17/66: Support multiple-width chars in annotations,
Dmitry Gutov <=
- [elpa] master ea5c4fd 05/66: More cleanup, Dmitry Gutov, 2015/01/12
- [elpa] master b188c49 07/66: Inline company-cmake--find-match, Dmitry Gutov, 2015/01/12
- [elpa] master 556ee69 16/66: Bump the version for development, Dmitry Gutov, 2015/01/12
- [elpa] master ccc08c9 08/66: Eliminate one `setq', Dmitry Gutov, 2015/01/12
- [elpa] master ed86ad5 20/66: company-update-candidates: Fix WRT ignore-case, Dmitry Gutov, 2015/01/12
- [elpa] master abf95f7 19/66: company-update-candidates: Don't be fooled by a few prefix completions, Dmitry Gutov, 2015/01/12
- [elpa] master 98477e7 21/66: Reword comment, Dmitry Gutov, 2015/01/12
- [elpa] master 660cafc 22/66: company-input-noop: Use a symbol for the dummy event binding, Dmitry Gutov, 2015/01/12
- [elpa] master 7d3c5d4 23/66: company-backends: Clarify that responding to `match' is never mandatory, Dmitry Gutov, 2015/01/12
- [elpa] master bb0badd 25/66: Edit NEWS, Dmitry Gutov, 2015/01/12