From d0bd880af7ba0b4ff6743ceca2536841aa39142a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Thu, 17 Apr 2025 20:21:16 +0300 Subject: [PATCH] * 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). (cherry picked from commit 2808bef2522481b3b3e6a7f2739ae8dbd02c13f5) --- lisp/treesit.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/treesit.el b/lisp/treesit.el index 009c219dd9f..ec4ddce5ae9 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -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))) -- 2.39.5