emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master c280e64 01/78: company-safe-substring: Honor the current b


From: Dmitry Gutov
Subject: [elpa] master c280e64 01/78: company-safe-substring: Honor the current buffer-invisibility-spec
Date: Sun, 18 Feb 2018 07:40:09 -0500 (EST)

branch: master
commit c280e6485a2a51eb18e75a8f6f2b074801b59ba2
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    company-safe-substring: Honor the current buffer-invisibility-spec
    
    Fixes #693
---
 company.el              | 30 ++++++++++++++++--------------
 test/frontends-tests.el |  8 ++++++++
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/company.el b/company.el
index 4f13dd1..233a1d1 100644
--- a/company.el
+++ b/company.el
@@ -2170,20 +2170,22 @@ character, stripping the modifiers.  That character 
must be a digit."
     (make-string len ?\ )))
 
 (defun company-safe-substring (str from &optional to)
-  (if (> from (string-width str))
-      ""
-    (with-temp-buffer
-      (insert str)
-      (move-to-column from)
-      (let ((beg (point)))
-        (if to
-            (progn
-              (move-to-column to)
-              (concat (buffer-substring beg (point))
-                      (let ((padding (- to (current-column))))
-                        (when (> padding 0)
-                          (company-space-string padding)))))
-          (buffer-substring beg (point-max)))))))
+  (let ((bis buffer-invisibility-spec))
+    (if (> from (string-width str))
+        ""
+      (with-temp-buffer
+        (setq buffer-invisibility-spec bis)
+        (insert str)
+        (move-to-column from)
+        (let ((beg (point)))
+          (if to
+              (progn
+                (move-to-column to)
+                (concat (buffer-substring beg (point))
+                        (let ((padding (- to (current-column))))
+                          (when (> padding 0)
+                            (company-space-string padding)))))
+            (buffer-substring beg (point-max))))))))
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
diff --git a/test/frontends-tests.el b/test/frontends-tests.el
index 0f7c19e..7212c3f 100644
--- a/test/frontends-tests.el
+++ b/test/frontends-tests.el
@@ -367,6 +367,14 @@
              (company-modify-line str "zz" 10)
              "-*-foobar zz"))))
 
+(ert-deftest company-modify-line-with-invisible-prop ()
+  (let ((str "-*-foobar")
+        (buffer-invisibility-spec '((outline . t) t)))
+    (put-text-property 1 2 'invisible 'foo str)
+    (should (equal
+             (company-modify-line str "zz" 4)
+             "-*-fzzbar"))))
+
 (ert-deftest company-scrollbar-bounds ()
   (should (equal nil (company--scrollbar-bounds 0 3 3)))
   (should (equal nil (company--scrollbar-bounds 0 4 3)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]