[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
- [elpa] branch master updated (864af57 -> 7b37238), Dmitry Gutov, 2014/03/18
- [elpa] 01/31: BBDB completion in message-mode, Dmitry Gutov, 2014/03/18
- [elpa] 07/31: Turn off company-tooltip-align-annotations by default, Dmitry Gutov, 2014/03/18
- [elpa] 04/31: Mention it in NEWS, Dmitry Gutov, 2014/03/18
- [elpa] 09/31: Reuse `company-auto-begin' in `company-idle-begin', Dmitry Gutov, 2014/03/18
- [elpa] 14/31: Fix indentation, Dmitry Gutov, 2014/03/18
- [elpa] 11/31: Remove superfluous statement, Dmitry Gutov, 2014/03/18
- [elpa] 10/31: company-auto-begin: wrap `company-begin' in `condition-case-no-debug', Dmitry Gutov, 2014/03/18
- [elpa] 12/31: Fix `args-out-of-bounds' error on formatting annotations when annotation start position is greater than the width of window.,
Dmitry Gutov <=
- [elpa] 05/31: Add user option company-tooltip-align-annotations, Dmitry Gutov, 2014/03/18
- [elpa] 15/31: Clear company-backend in company-auto-begin, Dmitry Gutov, 2014/03/18
- [elpa] 19/31: Highlight last annotation character, too, Dmitry Gutov, 2014/03/18
- [elpa] 13/31: Merge pull request #70 from sadboy/master, Dmitry Gutov, 2014/03/18
- [elpa] 18/31: company--multi-backend-adapter: noop when arg is empty, Dmitry Gutov, 2014/03/18
- [elpa] 16/31: Tag candidates from grouped backends, Dmitry Gutov, 2014/03/18
- [elpa] 17/31: Add company-yasnippet, Dmitry Gutov, 2014/03/18
- [elpa] 22/31: company-sort-by-occurrence: do stable sorting, Dmitry Gutov, 2014/03/18
- [elpa] 20/31: Fix company-yasnippet summary, Dmitry Gutov, 2014/03/18
- [elpa] 23/31: Define company-version, Dmitry Gutov, 2014/03/18