From: Yuan Fu Date: Wed, 23 Nov 2022 23:20:19 +0000 (-0800) Subject: Don't always filter out captured tree-sitter nodes outside of region X-Git-Tag: emacs-29.0.90~1551 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=00e7da76a7cf98239e9723624b1b5eb031636ce0;p=emacs.git 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. --- diff --git a/lisp/treesit.el b/lisp/treesit.el index 3140358167c..73a499bfa95 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