emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 05/14: Fix out-of-bounds error on truncated anno fontification


From: Dmitry Gutov
Subject: [elpa] 05/14: Fix out-of-bounds error on truncated anno fontification
Date: Tue, 18 Feb 2014 05:51:01 +0000

dgutov pushed a commit to branch master
in repository elpa.

commit 13f971a366c3402aa691443a6b204f1ad3631aab
Author: Dmitry Gutov <address@hidden>
Date:   Sun Feb 9 18:32:40 2014 +0200

    Fix out-of-bounds error on truncated anno fontification
---
 company-tests.el |   16 ++++++++++++++++
 company.el       |    2 +-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/company-tests.el b/company-tests.el
index 9272f25..8b56fec 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -334,6 +334,22 @@
     (should (equal '(" x 1 " " y 2 " " z 3 ")
                    (company--create-lines 0 999)))))
 
+(ert-deftest company-create-lines-truncates-annotations ()
+  (let* ((ww (company--window-width))
+         (data `(("1" . "(123)")
+                 ("2" . nil)
+                 ("3" . ,(concat "(" (make-string (- ww 2) ?4) ")"))))
+         (company-candidates (mapcar #'car data))
+         (company-candidates-length 3)
+         (company-tooltip-margin 1)
+         (company-backend (lambda (cmd &optional arg)
+                            (when (eq cmd 'annotation)
+                              (cdr (assoc arg data))))))
+    (should (equal (list (format " 1(123)%s " (company-space-string (- ww 8)))
+                         (format " 2%s " (company-space-string (- ww 3)))
+                         (format " 3(444%s " (make-string (- ww 7) ?4)))
+                   (company--create-lines 0 999)))))
+
 (ert-deftest company-column-with-composition ()
   (with-temp-buffer
     (insert "lambda ()")
diff --git a/company.el b/company.el
index c67485f..235e8e1 100644
--- a/company.el
+++ b/company.el
@@ -1853,7 +1853,7 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" 
\"foobarbaz\"\)\)"
                          '(face company-tooltip-common
                            mouse-face company-tooltip-mouse)
                          line)
-    (add-text-properties ann-start (+ ann-start (length annotation))
+    (add-text-properties ann-start (min (+ ann-start (length annotation)) 
width)
                          '(face company-tooltip-annotation
                            mouse-face company-tooltip-mouse)
                          line)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]