emacs-diffs
[Top][All Lists]
Advanced

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

master 8f260bb93f5: Don't update ranges for the whole buffer in treesit-


From: Yuan Fu
Subject: master 8f260bb93f5: Don't update ranges for the whole buffer in treesit--pre-redisplay
Date: Mon, 19 Feb 2024 00:44:40 -0500 (EST)

branch: master
commit 8f260bb93f534b24d9a93d3315804ffe0c1fec4f
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Don't update ranges for the whole buffer in treesit--pre-redisplay
    
    * lisp/treesit.el (treesit--pre-redisplay): Only update two
    screen-full of text around point.
---
 lisp/treesit.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index f811b8090bc..fa82ad898a9 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1382,7 +1382,15 @@ as comment due to incomplete parse tree."
     ;; `treesit-update-ranges' will force the host language's parser to
     ;; reparse and set correct ranges for embedded parsers.  Then
     ;; `treesit-parser-root-node' will force those parsers to reparse.
-    (treesit-update-ranges)
+    (let ((len (+ (* (window-body-height) (window-body-width)) 800)))
+      ;; FIXME: As a temporary fix, this prevents Emacs from updating
+      ;; every single local parsers in the buffer every time there's an
+      ;; edit.  Moving forward, we need some way to properly track the
+      ;; regions which need update on parser ranges, like what jit-lock
+      ;; and syntax-ppss does.
+      (treesit-update-ranges
+       (max (point-min) (- (point) len))
+       (min (point-max) (+ (point) len))))
     ;; Force repase on _all_ the parsers might not be necessary, but
     ;; this is probably the most robust way.
     (dolist (parser (treesit-parser-list))



reply via email to

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