[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 16/28: company-buffer-lines: handle multiline display better
From: |
Dmitry Gutov |
Subject: |
[elpa] 16/28: company-buffer-lines: handle multiline display better |
Date: |
Wed, 27 Aug 2014 01:26:28 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit e40329f6b4af7557c4651d33fcf7d3ba93c58041
Author: Dmitry Gutov <address@hidden>
Date: Mon Aug 18 05:51:10 2014 +0400
company-buffer-lines: handle multiline display better
Improves #136.
---
company-tests.el | 14 ++++++++++++++
company.el | 8 ++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/company-tests.el b/company-tests.el
index 898fb92..33e0c98 100644
--- a/company-tests.el
+++ b/company-tests.el
@@ -597,6 +597,20 @@
(company-plainify (propertize "foobar" 'line-prefix "-*-"))
"-*-foobar")))
+(ert-deftest company-buffer-lines-with-lines-folded ()
+ (with-temp-buffer
+ (insert (propertize "aaa\nbbb\nccc\nddd\n" 'display "aaa+\n"))
+ (insert "eee\nfff\nggg")
+ (should (equal (company-buffer-lines (point-min) (point-max))
+ '("aaa" "eee" "fff" "ggg")))))
+
+(ert-deftest company-buffer-lines-with-multiline-display ()
+ (with-temp-buffer
+ (insert (propertize "a" 'display "bbb\nccc\ndddd\n"))
+ (insert "eee\nfff\nggg")
+ (should (equal (company-buffer-lines (point-min) (point-max))
+ '("" "" "" "eee" "fff" "ggg")))))
+
(ert-deftest company-modify-line ()
(let ((str "-*-foobar"))
(should (equal-including-properties
diff --git a/company.el b/company.el
index e9ada82..bbaea00 100644
--- a/company.el
+++ b/company.el
@@ -2169,8 +2169,8 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(defun company-buffer-lines (beg end)
(goto-char beg)
- (let (lines)
- (while (and (= 1 (vertical-motion 1))
+ (let (lines lines-moved)
+ (while (and (> (setq lines-moved (vertical-motion 1)) 0)
(<= (point) end))
(let ((bound (min end (1- (point)))))
;; A visual line can contain several physical lines (e.g. with
outline's
@@ -2181,6 +2181,10 @@ If SHOW-VERSION is non-nil, show the version in the echo
area."
(re-search-forward "$" bound 'move)
(point)))
lines))
+ ;; One physical line can be displayed as several visual ones as well:
+ ;; add empty strings to the list, to even the count.
+ (dotimes (_ (1- lines-moved))
+ (push "" lines))
(setq beg (point)))
(unless (eq beg end)
(push (buffer-substring beg end) lines))
- [elpa] 02/28: company-dabbrev--search-buffer: Use `syntax-ppss' to get to the beg of str-or-cmt, (continued)
- [elpa] 02/28: company-dabbrev--search-buffer: Use `syntax-ppss' to get to the beg of str-or-cmt, Dmitry Gutov, 2014/08/26
- [elpa] 04/28: Remove the "download ERT" logic; should be unused at this point, Dmitry Gutov, 2014/08/26
- [elpa] 08/28: Assign a face for the tooltip search string, Dmitry Gutov, 2014/08/26
- [elpa] 09/28: Merge pull request #164 from holomorph/tooltip-search, Dmitry Gutov, 2014/08/26
- [elpa] 10/28: Mention company-tooltip-search in NEWS, Dmitry Gutov, 2014/08/26
- [elpa] 11/28: Use window-screen-lines when available, Dmitry Gutov, 2014/08/26
- [elpa] 05/28: company--show-inline-p: never ignore case, Dmitry Gutov, 2014/08/26
- [elpa] 12/28: Tweak wording, Dmitry Gutov, 2014/08/26
- [elpa] 13/28: Use `posn-actual-col-row' to determine the current col and row, Dmitry Gutov, 2014/08/26
- [elpa] 14/28: Work around http://debbugs.gnu.org/18285, Dmitry Gutov, 2014/08/26
- [elpa] 16/28: company-buffer-lines: handle multiline display better,
Dmitry Gutov <=
- [elpa] 17/28: company-input-noop still seems to be needed in the terminal, Dmitry Gutov, 2014/08/26
- [elpa] 18/28: Skip company-buffer-lines tests in terminal, Dmitry Gutov, 2014/08/26
- [elpa] 19/28: company-pseudo-tooltip-unhide: use local vars, Dmitry Gutov, 2014/08/26
- [elpa] 20/28: company-pseudo-tooltip-unhide: fix rendering at eob, Dmitry Gutov, 2014/08/26
- [elpa] 15/28: Fix the tests, Dmitry Gutov, 2014/08/26
- [elpa] 21/28: Add a comment, Dmitry Gutov, 2014/08/26
- [elpa] 22/28: company--capf-data: use caching, Dmitry Gutov, 2014/08/26
- [elpa] 24/28: Use `company-dabbrev-ignore-case' when searching for candidates, Dmitry Gutov, 2014/08/26
- [elpa] 25/28: Document `company-dabbrev-ignore-case' better, Dmitry Gutov, 2014/08/26
- [elpa] 26/28: company-dabbrev-code-ignore-case: rephrase a bit, Dmitry Gutov, 2014/08/26