emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 b429e524288: Improve tree-sitter fontification in edge-cases (b


From: Yuan Fu
Subject: emacs-29 b429e524288: Improve tree-sitter fontification in edge-cases (bug#59738)
Date: Wed, 7 Dec 2022 19:05:35 -0500 (EST)

branch: emacs-29
commit b429e52428851145f8c483acdbb106ba0a0ed2be
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Improve tree-sitter fontification in edge-cases (bug#59738)
    
    * lisp/treesit.el (treesit-font-lock-fontify-region): Use
    treesit--children-covering-range-recurse.
---
 lisp/treesit.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index dbbf7ec18c3..5e87737659e 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -888,6 +888,12 @@ detail.")
 ;; top-level nodes and query them.  This ensures that querying is fast
 ;; everywhere else, except for the problematic region.
 ;;
+;; Some other time the source file has a top-level node that contains
+;; a huge number of children (say, 10k children), querying that node
+;; is also very slow, so instead of getting the top-level node, we
+;; recursively go down the tree to find nodes that cover the region
+;; but are reasonably small.
+;;
 ;; 3. It is possible to capture a node that's completely outside the
 ;; region between START and END: as long as the whole pattern
 ;; intersects the region, all the captured nodes in that pattern are
@@ -917,8 +923,8 @@ If LOUDLY is non-nil, display some debugging information."
         ;; If we run into problematic files, use the "fast mode" to
         ;; try to recover.  See comment #2 above for more explanation.
         (when treesit--font-lock-fast-mode
-          (setq nodes (treesit--children-covering-range
-                       (car nodes) start end)))
+          (setq nodes (treesit--children-covering-range-recurse
+                       (car nodes) start end (* 4 jit-lock-chunk-size))))
 
         ;; Query each node.
         (dolist (sub-node nodes)



reply via email to

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