[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars bb43583789 336/431: invalidate using all wi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars bb43583789 336/431: invalidate using all window ranges showing current buffer |
Date: |
Mon, 16 Sep 2024 12:59:47 -0400 (EDT) |
branch: externals/indent-bars
commit bb4358378999d4b7ee5894c664902a542f38c785
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
invalidate using all window ranges showing current buffer
In addition to the "wide" window clip of the current window,
invalidate font-lock across the union of all other window ranges
showing the same buffer.
---
indent-bars-ts.el | 49 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 7567f3eaba..47b6a121a7 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -314,6 +314,21 @@ of ranges that either cover."
(list a b) ; no overlap, use both
(list (cons (car a) (max (cdr a) (cdr b))))))
+(defun indent-bars-ts--union-all (ranges)
+ "Return the union of all ranges in the list RANGES.
+Each range is a (start . end) cons."
+ (let* ((ranges (sort ranges (lambda (a b) (< (car a) (car b)))))
+ (u ranges)
+ (cur (car ranges))
+ new)
+ (dolist (r (cdr ranges))
+ (setq u (indent-bars-ts--union cur r))
+ (if (= (length u) 1)
+ (setq cur (car u))
+ (push (car u) new)
+ (setq u (cdr u) cur (car u))))
+ (append u new)))
+
(defun indent-bars-ts--intersection (a b)
"Return the intersection between ranges A and B.
Ranges A and B are (start . end) conses. Their intersection is a
@@ -358,8 +373,9 @@ ranges and update. Note that the updated node range clips
to an
(= (buffer-modified-tick) (ibts/tick ibtcs))))
(setf (ibts/tick ibtcs) (buffer-modified-tick)
(ibts/point ibtcs) (point))
- (let* ((node (treesit-node-on
- (max (point-min) (1- (point))) (point)
+ (let* ((pmn (point-min)) (pmx (point-max))
+ (node (treesit-node-on
+ (max pmn (1- (point))) (point)
indent-bars-ts--parser))
(scope (and node
(indent-bars-ts--node-query
@@ -370,26 +386,35 @@ ranges and update. Note that the updated node range
clips to an
(win (cons (window-start) (window-end)))
(new (if scope ; no scope = full file
(cons (treesit-node-start scope) (treesit-node-end
scope))
- (cons (point-min) (point-max)))))
+ (cons pmn pmx))))
(unless (and (= (car new) (car old)) ; if node is unchanged (spans
(= (cdr new) (cdr old)) ; the same positions) and the
(>= (car win) (car old-clip)) ; window is inside old
clip range:
(<= (cdr win) (cdr old-clip))) ; no update needed
(let* ((marg (/ (- (cdr win) (car win)) 2)) ; add a bit of space
- (clip-wide (cons (max (point-min) (- (car win) marg))
- (min (point-max) (+ (cdr win) marg)))))
- (setf (ibts/start-bars ibtcs)
+ (wide-clip (cons (max pmn (- (car win) marg))
+ (min pmx (+ (cdr win) marg))))
+ (wins (get-buffer-window-list nil nil t))
+ (all-clips ; across all windows showing this buf
+ (indent-bars-ts--union-all
+ (append (mapcar
+ (lambda (w)
+ (cons (window-start w) (window-end w)))
+ (cdr wins))
+ (list wide-clip)))))
+ (setf (indent-bars-ts-scope-start-bars
indent-bars-ts-current-scope)
(save-excursion
(goto-char (car new))
(indent-bars--current-indentation-depth)))
- (cl-loop for rng in (indent-bars-ts--union old new)
- for (beg . end) = (indent-bars-ts--intersection rng
clip-wide)
- if (and beg end) do
- (font-lock-flush beg end))
+ (dolist (rng (indent-bars-ts--union old new))
+ (cl-loop
+ for wc in all-clips
+ for (beg . end) = (indent-bars-ts--intersection rng wc)
+ if (and beg end (> end beg)) do (font-lock-flush beg end)))
(set-marker (car old) (car new))
(set-marker (cdr old) (cdr new))
- (set-marker (car old-clip) (car clip-wide))
- (set-marker (cdr old-clip) (cdr clip-wide)))))))))
+ (set-marker (car old-clip) (car wide-clip))
+ (set-marker (cdr old-clip) (cdr wide-clip)))))))))
(defun indent-bars-ts--update-scope ()
"Update treesit scope when possible."
- [elpa] externals/indent-bars 86113c74ee 298/431: docs: minor tweaks, (continued)
- [elpa] externals/indent-bars 86113c74ee 298/431: docs: minor tweaks, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 71b787c7d0 294/431: display: goto BEG prior to checking indentation depth, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b433c5ca4d 308/431: TS: add developer note, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4d1e7db294 309/431: TS: remove debug message, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars e20ba1caea 304/431: Improve README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 8cccb685b1 305/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7a1413cb15 314/431: Ensure buffer-local idle timers run in the original buffer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars adbf859e2d 323/431: Update README.md — blank spacer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 21f6242b24 321/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 751db47d31 341/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars bb43583789 336/431: invalidate using all window ranges showing current buffer,
ELPA Syncer <=
- [elpa] externals/indent-bars 3b738a1d10 333/431: README: ts out of scope style config improvements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0222bb453e 335/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 3ac1bd66a7 311/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c516788fe3 362/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2d88129b2a 327/431: Add small menu to README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 8826105182 342/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 88010c2724 387/431: Initial efforts towards font-lock-free/managing bars, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f64e33bf37 325/431: correctly test style tag string with #'equal, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars d84c654c22 320/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c6dab3309c 365/431: Remove superfluous :group from customs, ELPA Syncer, 2024/09/16