dgutov pushed a commit to branch master in repository elpa. commit 43b05ffa8a72d3bcce763285f8b1f4a907fa4011 Author: Dmitry Gutov <dgu...@yandex.ru> Date: Mon Jul 28 17:22:14 2014 +0300
company-fill-propertize: tuncate the common part Fixes #156 --- company-tests.el | 33 +++++++++++++++++++++++++++++++++ company.el | 7 ++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/company-tests.el b/company-tests.el index 005bf3a..fd2a42b 100644 --- a/company-tests.el +++ b/company-tests.el @@ -522,6 +522,39 @@ (format " %s " (make-string (- ww 2) ?4))) (company--create-lines 0 999)))))) +(ert-deftest company-create-lines-truncates-common-part () + (let* ((ww (company--window-width)) + (company-candidates-length 2) + (company-tooltip-margin 1) + (company-backend #'ignore)) + (let* ((company-common (make-string (- ww 3) ?1)) + (company-candidates `(,(concat company-common "2") + ,(concat company-common "3")))) + (should (equal (list (format " %s2 " (make-string (- ww 3) ?1)) + (format " %s3 " (make-string (- ww 3) ?1))) + (company--create-lines 0 999)))) + (let* ((company-common (make-string (- ww 2) ?1)) + (company-candidates `(,(concat company-common "2") + ,(concat company-common "3")))) + (should (equal (list (format " %s " company-common) + (format " %s " company-common)) + (company--create-lines 0 999)))) + (let* ((company-common (make-string ww ?1)) + (company-candidates `(,(concat company-common "2") + ,(concat company-common "3"))) + (res (company--create-lines 0 999))) + (should (equal (list (format " %s " (make-string (- ww 2) ?1)) + (format " %s " (make-string (- ww 2) ?1))) + res)) + (should (eq 'company-tooltip-common-selection + (get-text-property (- ww 2) 'face + (car res)))) + (should (eq 'company-tooltip-selection + (get-text-property (1- ww) 'face + (car res)))) + +))) + (ert-deftest company-column-with-composition () (with-temp-buffer (insert "lambda ()") diff --git a/company.el b/company.el index 7b48347..ac49892 100644 --- a/company.el +++ b/company.el @@ -5,7 +5,7 @@ ;; Author: Nikolaj Schumacher ;; Maintainer: Dmitry Gutov <dgu...@yandex.ru> ;; URL: http://company-mode.github.io/ -;; Version: 0.8.2 +;; Version: 0.8.3-cvs ;; Keywords: abbrev, convenience, matching ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) @@ -2110,8 +2110,8 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (defun company-fill-propertize (value annotation width selected left right) (let* ((margin (length left)) - (common (+ (or (company-call-backend 'match value) - (length company-common)) margin)) + (common (or (company-call-backend 'match value) + (length company-common))) (ann-ralign company-tooltip-align-annotations) (ann-truncate (< width (+ (length value) (length annotation) @@ -2135,6 +2135,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (- width (length annotation))) annotation)) right))) + (setq common (+ (min common width) margin)) (setq width (+ width margin (length right))) (add-text-properties 0 width '(face company-tooltip