]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix tree-sitter range update function
authorYuan Fu <casouri@gmail.com>
Sat, 16 Sep 2023 16:03:16 +0000 (09:03 -0700)
committerYuan Fu <casouri@gmail.com>
Tue, 19 Sep 2023 03:48:54 +0000 (20:48 -0700)
* lisp/treesit.el (treesit-update-ranges): If an embedded language
doesn't have any range, don't set its range to nil (which means whole
buffer), instead, set its range to a dummy (1 . 1) zero range.

lisp/treesit.el

index 41ebc62fca6c7420c5688ef6299b1c4082ce8d3a..8163ffdf32909ec555455f725f65e272dacc2584 100644 (file)
@@ -544,7 +544,12 @@ region."
             (when (eq (treesit-parser-language parser)
                       language)
               (treesit-parser-set-included-ranges
-               parser set-ranges))))))))
+               parser (or set-ranges
+                          ;; When there's no range for the embedded
+                          ;; language, set it's range to a dummy (1
+                          ;; . 1), otherwise it would be set to the
+                          ;; whole buffer, which is not what we want.
+                          `((,(point-min) . ,(point-min))))))))))))
 
 (defun treesit-parser-range-on (parser beg &optional end)
   "Check if PARSER's range covers the portion between BEG and END.