branch: master commit dbb4c743dd2ffb3f05fde3870a5ccbf555b0865e Merge: c046847 7fc6ad9 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Merge branch 'master' of github.com:company-mode/company-mode --- NEWS.md | 1 + company.el | 14 +++++++++----- test/frontends-tests.el | 8 ++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1c623ec..25ec302 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,7 @@ map binding `TAB` to "jump to the next field"). Affects both `company-template` and `yasnippet` (requires changes from 2019-04-21, currently unreleased). +* New values for option `company-show-numbers` to show number on the left. ## 2019-04-15 (0.9.10) diff --git a/company.el b/company.el index 1ee7d4d..dedaa30 100644 --- a/company.el +++ b/company.el @@ -641,7 +641,8 @@ commands in the `company-' namespace, abort completion." (defcustom company-show-numbers nil "If enabled, show quick-access numbers for the first ten candidates." :type '(choice (const :tag "off" nil) - (const :tag "on" t))) + (const :tag "left" 'left) + (const :tag "on" 't))) (defcustom company-show-numbers-function #'company--show-numbers "Function called to get quick-access numbers for the first ten candidates. @@ -2817,17 +2818,20 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (let* ((item (pop items)) (str (car item)) (annotation (cdr item)) - (right (company-space-string company-tooltip-margin)) + (margin (company-space-string company-tooltip-margin)) + (left margin) + (right margin) (width width)) (when (< numbered 10) (cl-decf width 2) (cl-incf numbered) - (setq right (concat (funcall company-show-numbers-function numbered) right))) + (setf (if (eq company-show-numbers 'left) left right) + (concat (funcall company-show-numbers-function numbered) + margin))) (push (concat (company-fill-propertize str annotation width (equal i selection) - (company-space-string - company-tooltip-margin) + left right) (when scrollbar-bounds (company--scrollbar i scrollbar-bounds))) diff --git a/test/frontends-tests.el b/test/frontends-tests.el index 7212c3f..f7f578e 100644 --- a/test/frontends-tests.el +++ b/test/frontends-tests.el @@ -139,6 +139,14 @@ (should (equal '(" x 1 " " y 2 " " z 3 ") (company--create-lines 0 999))))) +(ert-deftest company-create-lines-shows-numbers-on-the-left () + (let ((company-show-numbers 'left) + (company-candidates '("x" "y" "z")) + (company-candidates-length 3) + (company-backend 'ignore)) + (should (equal '(" 1 x " " 2 y " " 3 z ") + (company--create-lines 0 999))))) + (ert-deftest company-create-lines-truncates-annotations () (let* ((ww (company--window-width)) (data `(("1" . "(123)")