branch: elpa/flycheck
commit 35b5397ba32d3c1035af03b3775cfbcb33c165c5
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Fix line-prefix preservation in narrowed buffers
    
    Use save-restriction/widen before get-text-property to handle the
    case where the overlay position is outside the current narrowed
    region.
---
 flycheck.el | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/flycheck.el b/flycheck.el
index ee537287bd..e245f6fe28 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -4833,10 +4833,12 @@ function resolves `conditional' style specifications."
       ;; Preserve any existing line-prefix text property (e.g. from
       ;; org-indent-mode) so the overlay doesn't clobber indentation.
       (when (buffer-live-p (overlay-buffer overlay))
-        (let ((existing-prefix (get-text-property
-                                (overlay-start overlay) 'line-prefix)))
-          (when existing-prefix
-            (setf (overlay-get overlay 'line-prefix) existing-prefix)))))
+        (save-restriction
+          (widen)
+          (let ((existing-prefix (get-text-property
+                                  (overlay-start overlay) 'line-prefix)))
+            (when existing-prefix
+              (setf (overlay-get overlay 'line-prefix) existing-prefix))))))
     (pcase (flycheck--highlighting-style err)
       ((or `nil (guard (null flycheck-highlighting-mode)))
        ;; Erase the highlighting

Reply via email to