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

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

[elpa] 12/31: Fix `args-out-of-bounds' error on formatting annotations w


From: Dmitry Gutov
Subject: [elpa] 12/31: Fix `args-out-of-bounds' error on formatting annotations when annotation start position is greater than the width of window.
Date: Tue, 18 Mar 2014 05:19:36 +0000

dgutov pushed a commit to branch master
in repository elpa.

commit b8d425753bb29187c60c784bf26a9238b496739d
Author: Bo Lin <address@hidden>
Date:   Sun Mar 2 10:48:45 2014 -0500

    Fix `args-out-of-bounds' error on formatting annotations when
    annotation start position is greater than the width of window.
    
    * company.el(company-fill-propertize): Check `ann-start' against
      `width' before adding annotation text properties.
    
    * company-tests.el(company-create-lines-truncates-annotations):
      Add test case.
---
 company-tests.el |   11 +++++++----
 company.el       |   10 ++++++----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/company-tests.el b/company-tests.el
index 2f8e51b..dca38b0 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -360,9 +360,10 @@
   (let* ((ww (company--window-width))
          (data `(("1" . "(123)")
                  ("2" . nil)
-                 ("3" . ,(concat "(" (make-string (- ww 2) ?4) ")"))))
+                 ("3" . ,(concat "(" (make-string (- ww 2) ?4) ")"))
+                 (,(make-string ww ?4) . "<4>")))
          (company-candidates (mapcar #'car data))
-         (company-candidates-length 3)
+         (company-candidates-length 4)
          (company-tooltip-margin 1)
          (company-backend (lambda (cmd &optional arg)
                             (when (eq cmd 'annotation)
@@ -370,12 +371,14 @@
          company-tooltip-align-annotations)
     (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)))
+                         (format " 3(444%s " (make-string (- ww 7) ?4))
+                         (format " %s " (make-string (- ww 2) ?4)))
                    (company--create-lines 0 999)))
     (let ((company-tooltip-align-annotations t))
       (should (equal (list (format " 1%s(123) " (company-space-string (- ww 
8)))
                            (format " 2%s " (company-space-string (- ww 3)))
-                           (format " 3 (444%s " (make-string (- ww 8) ?4)))
+                           (format " 3 (444%s " (make-string (- ww 8) ?4))
+                           (format " %s " (make-string (- ww 2) ?4)))
                      (company--create-lines 0 999))))))
 
 (ert-deftest company-column-with-composition ()
diff --git a/company.el b/company.el
index 44f5df5..ca043e3 100644
--- a/company.el
+++ b/company.el
@@ -1873,6 +1873,7 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" 
\"foobarbaz\"\)\)"
                                (1+ (length value))
                              (- width (length annotation)))
                          (length value))))
+         (ann-end (min (+ ann-start (length annotation)) width))
          (line (concat left
                        (if (or ann-truncate (not ann-ralign))
                            (company-safe-substring
@@ -1894,10 +1895,11 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" 
\"foobarbaz\"\)\)"
                          '(face company-tooltip-common
                            mouse-face company-tooltip-mouse)
                          line)
-    (add-text-properties ann-start (min (+ ann-start (length annotation)) 
width)
-                         '(face company-tooltip-annotation
-                           mouse-face company-tooltip-mouse)
-                         line)
+    (when (< ann-start ann-end)
+      (add-text-properties ann-start ann-end
+                           '(face company-tooltip-annotation
+                                  mouse-face company-tooltip-mouse)
+                           line))
     (when selected
       (if (and company-search-string
                (string-match (regexp-quote company-search-string) value



reply via email to

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