* lisp/treesit.el (treesit-parsers-at): Fix for 'with-host' arg.

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).
This commit is contained in:
Juri Linkov 2025-04-17 20:21:16 +03:00
parent 4c5c20ddc2
commit 2808bef252

View file

@ -873,10 +873,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)))