emacs-diffs
[Top][All Lists]
Advanced

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

master 00e7da76a7 1/5: Don't always filter out captured tree-sitter node


From: Yuan Fu
Subject: master 00e7da76a7 1/5: Don't always filter out captured tree-sitter nodes outside of region
Date: Wed, 23 Nov 2022 22:50:56 -0500 (EST)

branch: master
commit 00e7da76a7cf98239e9723624b1b5eb031636ce0
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Don't always filter out captured tree-sitter nodes outside of region
    
    * lisp/treesit.el (treesit-font-lock-fontify-region): If the capture
    name is a function, don't filter.
---
 lisp/treesit.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index 3140358167..73a499bfa9 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -912,12 +912,17 @@ If LOUDLY is non-nil, display some debugging information."
                        (node (cdr capture))
                        (node-start (treesit-node-start node))
                        (node-end (treesit-node-end node)))
-                  ;; Turns out it is possible to capture a node that's
+                  ;; It is possible to capture a node that's
                   ;; completely outside the region between START and
-                  ;; END.  If the node is outside of that region, (max
-                  ;; node-start start) and friends return bad values.
-                  (when (and (< start node-end)
-                             (< node-start end))
+                  ;; END: as long as the whole pattern intersects the
+                  ;; region, all the captured nodes in that pattern
+                  ;; are returned.  If the node is outside of that
+                  ;; region, (max node-start start) and friends return
+                  ;; bad values.
+                  (if (and (facep face) (or (>= start node-end)
+                                            (>= node-start end)))
+                      (when (or loudly treesit--font-lock-verbose)
+                        (message "Captured node %s(%s-%s) but it is outside of 
fontifing region" node node-start node-end))
                     (cond
                      ((facep face)
                       (treesit-fontify-with-override



reply via email to

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