(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
(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
(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))