]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/treesit.el (treesit-parsers-at): Fix for 'with-host' arg.
authorJuri Linkov <juri@linkov.net>
Thu, 17 Apr 2025 17:21:16 +0000 (20:21 +0300)
committerEshel Yaron <me@eshelyaron.com>
Fri, 18 Apr 2025 06:46:51 +0000 (08:46 +0200)
Don't add the primary parser or the first of treesit-parser-list
when non-nil 'with-host' is provided since there is no host
for the primary parser (bug#76788).

(cherry picked from commit 2808bef2522481b3b3e6a7f2739ae8dbd02c13f5)

lisp/treesit.el

index 009c219dd9f120035a55a541dc4526c8b76de485..ec4ddce5ae96513ccdaf32956d266a3e04d94279 100644 (file)
@@ -872,10 +872,10 @@ If ONLY contains the symbol `primary', include the primary parser."
                          (and (memq 'global only)
                               (not (overlay-get ov 'treesit-parser-local-p))))))
         (push (if with-host (cons parser host-parser) parser) res)))
-    (when (and treesit-primary-parser (or (null only) (memq 'primary only)))
-      (push treesit-primary-parser res))
-    (unless res
-      (push (car (treesit-parser-list)) res))
+    (when (and (not with-host) (or (null only) (memq 'primary only)))
+      (push (or treesit-primary-parser
+                (car (treesit-parser-list)))
+            res))
     (seq-sort-by (lambda (p)
                    (treesit-parser-embed-level
                     (or (car-safe p) p)))