diff --git a/lisp/treesit.el b/lisp/treesit.el index 41ebc62fca6..8163ffdf329 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -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.