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

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

[elpa] externals/indent-bars 959e978986 385/431: invalid ranges: use cus


From: ELPA Syncer
Subject: [elpa] externals/indent-bars 959e978986 385/431: invalid ranges: use custom marker cache
Date: Mon, 16 Sep 2024 12:59:53 -0400 (EDT)

branch: externals/indent-bars
commit 959e978986e7023bc29904b0bc8a24fbc4eae23f
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>

    invalid ranges: use custom marker cache
    
    intersect was returning sometimes the old markers, whose positions get 
updated.
---
 indent-bars-ts.el | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 6d52d31e09..9e0a65b56c 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -381,10 +381,29 @@ ranges of the current scope."
         (scope (buffer-local-value 'ibtcs (window-buffer win)))
         (rngs (indent-bars-ts--intersect-all
                (cons start end) (ibts/invalid-ranges scope))))
-    (message "On scroll with %S: %d" (selected-window) start)
+    ;; (message "WS: %s %d" win start)
     (cl-loop for (beg . end) in rngs do
             (indent-bars-ts--add-bars-in-range beg end))))
 
+(defvar-local indent-bars-ts--invalid-range-markers nil)
+(defun indent-bars-ts--update-invalid-ranges (ranges)
+  "Update invalid ranges for the current scope with RANGES.
+Also sets the `indent-bars-invalid' property on the indicates
+ranges.  Re-uses markers for efficiency."
+  (let* ((lm (length indent-bars-ts--invalid-range-markers))
+        (lr (length ranges)))
+    (when (> lr lm)
+      (dotimes (_ (- lr lm))
+       (push (cons (make-marker) (make-marker))
+             indent-bars-ts--invalid-range-markers))
+      (setq lm lr))
+    (setf (ibts/invalid-ranges ibtcs)
+         (nthcdr (- lm lr) indent-bars-ts--invalid-range-markers))
+    (cl-loop for (beg . end) in ranges
+            for (mbeg . mend) in (ibts/invalid-ranges ibtcs) do
+            (put-text-property beg end 'indent-bars-invalid t)
+            (set-marker mbeg beg) (set-marker mend end))))
+
 (defun indent-bars-ts--update-scope1 (buf)
   "Perform the treesitter scope font-lock update in buffer BUF.
 Re-query the scope node at point, and if it has moved (beyond
@@ -413,9 +432,7 @@ window."
                (save-excursion
                  (goto-char (car new))
                  (indent-bars--current-indentation-depth)))
-         (setf (ibts/invalid-ranges ibtcs) (indent-bars-ts--union old new))
-         (cl-loop for (beg . end) in (ibts/invalid-ranges ibtcs) do
-                  (put-text-property beg end 'indent-bars-invalid t))
+         (indent-bars-ts--update-invalid-ranges (indent-bars-ts--union old 
new))
          (set-marker (car old) (car new)) ;updates ibts/range
          (set-marker (cdr old) (cdr new))
          ;; Arrange to check the current window's bars, just in case



reply via email to

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