[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 5a3346b68c 386/431: Remove invalid-ranges
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 5a3346b68c 386/431: Remove invalid-ranges |
Date: |
Mon, 16 Sep 2024 12:59:53 -0400 (EDT) |
branch: externals/indent-bars
commit 5a3346b68c63557f26530a40f05e8b3b94569416
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Remove invalid-ranges
These didn't work, since old regions can still need redraw.
---
indent-bars-ts.el | 98 +++++++++++++++++++++----------------------------------
1 file changed, 37 insertions(+), 61 deletions(-)
diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 9e0a65b56c..1fbe10f832 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -280,9 +280,6 @@ mentioned in
`indent-bars-treesit-ignore-blank-lines-types'."
:documentation "The current scope node's range.")
( start-bars 0 :type integer
:documentation "The number of bars shown at start of current scope.")
- ( invalid-ranges nil :type list
- :documentation "List of current invalid ranges.
-One or more (start . end) conses.")
( query nil :type ts-query
:documentation "The treesitter scope query object."))
@@ -373,36 +370,41 @@ range to clip against."
for i = (indent-bars-ts--intersection clip r)
if i collect i))
+(defun indent-bars-ts--add-bars-in-range (start end)
+ "Add bars if needed between START and END.
+Bars are added on all visible ranges of text (considering both
+text properties and overlays) with a non-nil
+`indent-bars-invalid' property. START is assumed to be visible.
+Based loosely on `jit-lock-function' and `jit-lock-fontify-now'."
+ (when-let ((invld-start (text-property-any start end 'indent-bars-invalid
t)))
+ (cl-loop for vs = invld-start then
+ (next-single-char-property-change ve 'indent-bars-invalid nil end)
+ for ve = (next-single-char-property-change vs 'indent-bars-invalid
nil end)
+ do
+ (put-text-property vs ve 'indent-bars-invalid nil)
+ (indent-bars-ts--draw-all-bars-between vs ve)
+ while (< ve end))
+ ;; (with-silent-modifications
+ ;; (save-match-data
+ ;; (cl-loop
+ ;; for vs = start then (next-single-char-property-change ve
'invisible nil end)
+ ;; for ve = (next-single-char-property-change vs 'invisible nil
end) do
+ ;; (cl-loop for (beg . end) in (indent-bars-ts--intersect-all
(cons vs ve) invld-rngs) do
+ ;; (put-text-property beg end 'indent-bars-invalid nil)
+ ;; (indent-bars-ts--draw-all-bars-between beg end))
+ ;; while (< ve end))))
+ ))
+
(defun indent-bars-ts--update-bars-on-scroll (win start)
- "Update bars as needed within the window WIN after START.
+ "Update bars as needed within the window WIN from START.
To be added to `window-scroll-functions'. Consults the invalid
ranges of the current scope."
- (let* ((end (window-end win t))
- (scope (buffer-local-value 'ibtcs (window-buffer win)))
- (rngs (indent-bars-ts--intersect-all
- (cons start end) (ibts/invalid-ranges scope))))
- ;; (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))))
+ (indent-bars-ts--add-bars-in-range (max (point-min) (- start
jit-lock-chunk-size))
+ (min (point-max) (+ (or (window-end win)
(+ start jit-lock-chunk-size))
+ jit-lock-chunk-size))
+ ;; (max (point-min) (- start
jit-lock-chunk-size))
+ ;; (min (point-max) (+ end
jit-lock-chunk-size))
+ ))
(defun indent-bars-ts--update-scope1 (buf)
"Perform the treesitter scope font-lock update in buffer BUF.
@@ -428,19 +430,17 @@ window."
(cons pmn pmx))))
(unless (and (= (car new) (car old)) ; if node is unchanged (spans
(= (cdr new) (cdr old))) ; same range) no update needed
+ (cl-loop for (beg . end) in (indent-bars-ts--union old new) do
+ (put-text-property beg end 'indent-bars-invalid t))
(setf (ibts/start-bars ibtcs)
(save-excursion
(goto-char (car new))
(indent-bars--current-indentation-depth)))
- (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
- ;; font-lock doesn't handle everything itself
- (run-at-time 0 nil (let ((win (selected-window)))
- (lambda ()
- (indent-bars-ts--update-bars-on-scroll
- win (window-start win))))))))))
+ (let ((win (selected-window)))
+ (indent-bars-ts--update-bars-on-scroll
+ win (window-start win))))))))
(defun indent-bars-ts--update-scope ()
"Update treesit scope when possible."
@@ -450,30 +450,6 @@ window."
#'indent-bars-ts--update-scope1
(current-buffer)))))
-(defun indent-bars-ts--add-bars-in-range (start end)
- "Add bars if needed between START and END.
-Bars are added on all visible ranges of text (considering both
-text properties and overlays) with a non-nil
-`indent-bars-invalid' property. START is assumed to be visible.
-Based loosely on `jit-lock-function' and `jit-lock-fontify-now'."
- (when-let ((invld-start (text-property-any start end 'indent-bars-invalid t))
- (invld-rngs
- (cl-loop for vs = invld-start then
- (next-single-char-property-change ve
'indent-bars-invalid nil end)
- for ve = (next-single-char-property-change vs
'indent-bars-invalid nil end)
- collect (cons vs ve) while (< ve end))))
- (message "abir: found some invalid ranges: %S" invld-rngs)
- (with-silent-modifications
- (save-match-data
- (cl-loop
- for vs = start then (next-single-char-property-change ve 'invisible
nil end)
- for ve = (next-single-char-property-change vs 'invisible nil end) do
- (cl-loop for (beg . end) in (indent-bars-ts--intersect-all (cons vs
ve) invld-rngs) do
- (message "Adding invalid bars %d:%d" beg end)
- (put-text-property beg end 'indent-bars-invalid nil)
- (indent-bars-ts--draw-all-bars-between beg end))
- while (< ve end))))))
-
;;;; Setup
(defun indent-bars-ts--init-scope (&optional force)
"Initialize scope style and variables.
- [elpa] externals/indent-bars d84c654c22 320/431: Update README.md, (continued)
- [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
- [elpa] externals/indent-bars 6677c94823 352/431: use end marker for invalid range(s), ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f7fb81c0d8 353/431: Major scope simplification: just invalid old ∪ new, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f986762207 328/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 34cecb96a4 358/431: Simplify developer note description for new simple font-lock method, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars adfab4df1e 359/431: styling-scope: new option to invert -ts- variable to apply in-scope, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars bcc1e69e1d 364/431: reset: leave indent-bars--styles alone for teardown, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4c1b2d46e9 367/431: introduce ts-minor-mode for simplified setup, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2d4dab01c6 377/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 5a3346b68c 386/431: Remove invalid-ranges,
ELPA Syncer <=
- [elpa] externals/indent-bars 6f429915ad 369/431: Bump version, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 48d6b40489 405/431: README: tweak ts-language tip, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars c8376cf437 416/431: Stipple compatibility update, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 1a88168837 389/431: indent-bars: refine jit-lock and extend region, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 76875aef81 401/431: slightly tweak main bar pattern and blend, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars aade176740 412/431: Merge pull request #52 from brownts/feature/ada-gpr, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars ca71453ad0 407/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars db7d4ba51d 388/431: Protect against custom-set reentry, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 79c21f2999 429/431: Assign copyright to FSF, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9fc2e57d38 420/431: Update README.md, ELPA Syncer, 2024/09/16