[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 8d8b0b964b 292/431: Do not test bol but poi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 8d8b0b964b 292/431: Do not test bol but point to skip scope update, simplify markers |
Date: |
Mon, 16 Sep 2024 12:59:40 -0400 (EDT) |
branch: externals/indent-bars
commit 8d8b0b964b47149359b75e834b620ccb6e872a5c
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Do not test bol but point to skip scope update, simplify markers
Scope can change based on position within the same line. Simplify the
setting markers. It may not be necessary to have the begin range be a
marker.
---
indent-bars-ts.el | 74 ++++++++++++++++++++++++++++---------------------------
1 file changed, 38 insertions(+), 36 deletions(-)
diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 745ca89031..69aaaa9acf 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -222,8 +222,8 @@ mentioned in
`indent-bars-treesit-ignore-blank-lines-types'."
:documentation "The clipping window for the current scope.")
( start-bars 0 :type integer
:documentation "The number of bars shown at start of current scope.")
- ( bol-point -1 :type integer
- :documentation "Point at line beginning during last scope update.")
+ ( point -1 :type integer
+ :documentation "Point during last scope update.")
( tick 0 :type integer
:documentation "Buffer modification tick at last scope update.")
( query nil :type ts-query
@@ -314,40 +314,42 @@ marker movement), refontify the union of old and new
clipped
ranges and update. Note that the updated node range clips to an
\"extended window\" with 50% padding on either side."
(setq indent-bars-ts--scope-timer nil)
- (let ((lbp (line-beginning-position)))
- (unless (or (not ibtcs) ; can be called from other buffers!
- (and (= lbp (ibts/bol-point ibtcs))
- (= (buffer-modified-tick) (ibts/tick ibtcs))))
- (when-let ((node (treesit-node-on
- (max (point-min) (1- (point))) (point)
- indent-bars-ts--parser))
- (scope (indent-bars-ts--node-query
- node (ibts/query ibtcs) nil 'innermost
- indent-bars-treesit-scope-min-lines)))
- (let* ((old (ibts/range ibtcs)) ;old node range markers
- (old-clip (ibts/clip-win ibtcs)) ;old clipping window
- (win (cons (window-start) (window-end)))
- (new (cons (treesit-node-start scope) (treesit-node-end scope))))
- (unless (and (equal new old) ; if node is the same and
- (>= (car win) (car old-clip)) ; window inside old range:
- (<= (cdr win) (cdr old-clip))) ; no update needed
- (let* ((marg (/ (- (cdr win) (car win)) 2)) ; a bit of space
- (clip-wide (cons (max (point-min) (- (car win) marg))
- (min (point-max) (+ (cdr win) marg)))))
- (setf (ibts/tick ibtcs) (buffer-modified-tick)
- (ibts/bol-point ibtcs) lbp
- (ibts/start-bars ibtcs)
- (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)
- do (font-lock-flush beg end))
- (dolist (fn '(car cdr))
- (set-marker (funcall fn (ibts/range ibtcs))
- (funcall fn new))
- (set-marker (funcall fn (ibts/clip-win ibtcs))
- (funcall fn clip-wide))))))))))
+ (unless (or (not ibtcs) ; can be called from other buffers!
+ (and (= (point) (ibts/point ibtcs))
+ (= (buffer-modified-tick) (ibts/tick ibtcs))))
+ (setf (ibts/tick ibtcs) (buffer-modified-tick)
+ (ibts/point ibtcs) (point))
+ (when-let ((node (treesit-node-on
+ (max (point-min) (1- (point))) (point)
+ indent-bars-ts--parser))
+ (scope (indent-bars-ts--node-query
+ node (ibts/query ibtcs) nil 'innermost
+ indent-bars-treesit-scope-min-lines)))
+ (let* ((old (ibts/range ibtcs)) ;old node range markers
+ (old-clip (ibts/clip-win ibtcs)) ;old clipping window
+ (win (cons (window-start) (window-end)))
+ (new (cons (treesit-node-start scope) (treesit-node-end scope))))
+ (unless (and (= (car new) (car old)) ; if node spans the
+ (= (cdr new) (cdr old)) ; same positions and the
+ (>= (car win) (car old-clip)) ; window is inside old 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)
+ (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
+ (message "Flushing %d lines" (count-lines beg end))
+ (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))))))))
(defun indent-bars-ts--update-scope ()
"Update treesit scope when possible."
- [elpa] externals/indent-bars bbc97b6c04 277/431: reset-styles for theme change, all face setup now via styles, (continued)
- [elpa] externals/indent-bars bbc97b6c04 277/431: reset-styles for theme change, all face setup now via styles, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 748ffeec7f 276/431: New highlight-method, including 'context (new default), ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ffaaae3d42 265/431: Remove styles on reset so that are recomputed, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f5f0392ab6 254/431: window-change: remap even if whr val unchanged, use remap-cleanup, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ceb2eb00e9 266/431: ppss-based no-descend-string/list, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 62d4a834b7 282/431: Restore use of base stipple-face-spec, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars d7af7b3d42 283/431: Restore unspecified for "parent decides" config, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 247b35f55d 286/431: on-bar tweaks and doc improvements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f80c712b37 288/431: update-current-depth-highlight: reindent, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9d374e0650 291/431: Fix timer teardown and run-hooks (which takes a hook name), ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 8d8b0b964b 292/431: Do not test bol but point to skip scope update, simplify markers,
ELPA Syncer <=
- [elpa] externals/indent-bars 4fa1058326 293/431: Never recreate the same style TAG, ELPA Syncer, 2024/09/16
- [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