]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't signal an error in treesit-node-at
authorYuan Fu <casouri@gmail.com>
Tue, 21 Jan 2025 04:36:41 +0000 (20:36 -0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 3 Feb 2025 11:09:43 +0000 (12:09 +0100)
* lisp/treesit.el (treesit-node-at): Wrap
treesit-buffer-root-node within condition-case.

(cherry picked from commit a9cde2463abd6677e9d44d306473beef00983aad)

lisp/treesit.el

index 4cca074c304caf1597b1c35effec84bc8598cdac..079187e3a540f1f0079012cde4d932c93fa38cba 100644 (file)
@@ -232,9 +232,11 @@ language and doesn't match the language of the local parser."
                                  (car (treesit-local-parsers-at
                                        pos parser-or-lang))))
                        (treesit-parser-root-node parser))
-                     (treesit-buffer-root-node
-                      (or parser-or-lang
-                          (treesit-language-at pos))))))
+                     (condition-case nil
+                         (treesit-buffer-root-node
+                          (or parser-or-lang
+                              (treesit-language-at pos)))
+                       (treesit-no-parser nil)))))
          (node root)
          (node-before root)
          (pos-1 (max (1- pos) (point-min)))