From 114ba5b76022f2980a7335e5224142adde59a6c4 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 23 Sep 2013 02:03:23 +0300 Subject: [PATCH] company--column: Account for line-prefix even at bol Again, for org-indent-mode. --- company-tests.el | 7 +++++++ company.el | 15 +++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/company-tests.el b/company-tests.el index 79d1f0257..1031d0bc7 100644 --- a/company-tests.el +++ b/company-tests.el @@ -210,6 +210,13 @@ (put-text-property (point-min) (point) 'line-prefix " ") (should (= (company--column) 5)))) +(ert-deftest company-column-wth-line-prefix-on-empty-line () + (with-temp-buffer + (insert "\n") + (forward-char -1) + (put-text-property (point-min) (point-max) 'line-prefix " ") + (should (= (company--column) 2)))) + (ert-deftest company-modify-line-with-line-prefix () (let ((str (propertize "foobar" 'line-prefix "-*-"))) (should (equal-including-properties diff --git a/company.el b/company.el index 40fdfa707..dff2e06b7 100644 --- a/company.el +++ b/company.el @@ -598,14 +598,13 @@ means that `company-mode' is always turned on except in `message-mode' buffers." (defun company--column (&optional pos) (save-excursion (when pos (goto-char pos)) - (let ((pt (point))) - (save-restriction - (+ (save-excursion - (vertical-motion 0) - (narrow-to-region (point) pt) - (let ((prefix (get-text-property (point) 'line-prefix))) - (if prefix (length prefix) 0))) - (current-column)))))) + (save-restriction + (+ (save-excursion + (vertical-motion 0) + (narrow-to-region (point) (point-max)) + (let ((prefix (get-text-property (point) 'line-prefix))) + (if prefix (length prefix) 0))) + (current-column))))) (defun company--row (&optional pos) (save-excursion -- 2.39.2