From 6e88174dae252d2fc1605ed84cb7252fd37ab98f Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 23 Jun 2015 03:06:51 +0300 Subject: [PATCH] Don't cut off the last character from a wrapped line Reported by Eli Zaretskii at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20847#68 --- company.el | 2 +- test/frontends-tests.el | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/company.el b/company.el index f0b1f1d70..5c20c0516 100644 --- a/company.el +++ b/company.el @@ -2350,7 +2350,7 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (while (and (not (eobp)) ; http://debbugs.gnu.org/19553 (> (setq lines-moved (vertical-motion 1)) 0) (<= (point) end)) - (let ((bound (min end (1- (point))))) + (let ((bound (min end (point)))) ;; A visual line can contain several physical lines (e.g. with outline's ;; folding overlay). Take only the first one. (push (buffer-substring beg diff --git a/test/frontends-tests.el b/test/frontends-tests.el index 613856e57..63f881e2e 100644 --- a/test/frontends-tests.el +++ b/test/frontends-tests.el @@ -299,7 +299,7 @@ (insert (propertize "a" 'display "bbb\nccc\ndddd\n")) (insert "eee\nfff\nggg") (should (equal (company-buffer-lines (point-min) (point-max)) - '("" "" "" "eee" "fff" "ggg"))))) + '("a" "" "" "eee" "fff" "ggg"))))) (ert-deftest company-buffer-lines-with-multiline-after-string-at-eob () :tags '(interactive) @@ -310,6 +310,16 @@ (should (equal (company-buffer-lines (point-min) (point-max)) '("a" "b" "c"))))) +(ert-deftest company-buffer-lines-with-line-wrapping () + :tags '(interactive) + (with-temp-buffer + (let ((ww (company--window-width))) + (insert (make-string (* 3 ww) ?a)) + (should (equal (company-buffer-lines (point-min) (point-max)) + (list (make-string ww ?a) + (make-string ww ?a) + (make-string ww ?a))))))) + (ert-deftest company-modify-line () (let ((str "-*-foobar")) (should (equal-including-properties -- 2.39.2