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)
committerYuan Fu <casouri@gmail.com>
Tue, 28 Jan 2025 01:55:54 +0000 (17:55 -0800)
* lisp/treesit.el (treesit-node-at): Wrap
treesit-buffer-root-node within condition-case.

lisp/treesit.el

index 2887521110b7d044ee00046eb59f2e3d60ae8684..2aa49a596d8db709cff23f2969aa7ea3ee2aec2f 100644 (file)
@@ -213,9 +213,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)))