[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 93a458f25f2: Fix treesit-node-at wrt local parsers
From: |
Yuan Fu |
Subject: |
master 93a458f25f2: Fix treesit-node-at wrt local parsers |
Date: |
Sat, 9 Sep 2023 15:37:03 -0400 (EDT) |
branch: master
commit 93a458f25f2a4730b9e24ae39cc25ad163697d53
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Fix treesit-node-at wrt local parsers
* lisp/treesit.el (treesit-node-at): Don't compute language at point
first. Because treesit-language-at uses treesit-node-at with a
language argument. Only call treesit-language-at when PARSER-OR-LANG
is nil.
---
lisp/treesit.el | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 1711446b40b..8371d0dda08 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -189,16 +189,18 @@ is a language, find the first parser for that language in
the
current buffer, or create one if none exists; If PARSER-OR-LANG
is nil, try to guess the language at POS using `treesit-language-at'.
-If there's a local parser at POS, try to use that parser first."
- (let* ((lang-at-point (treesit-language-at pos))
- (root (if (treesit-parser-p parser-or-lang)
+If there's a local parser at POS, the local parser takes priority
+unless PARSER-OR-LANG is a parser, or PARSER-OR-LANG is a
+language and doesn't match the language of the local parser."
+ (let* ((root (if (treesit-parser-p parser-or-lang)
(treesit-parser-root-node parser-or-lang)
- (or (when-let ((parser (car (treesit-local-parsers-at
- pos (or parser-or-lang
- lang-at-point)))))
+ (or (when-let ((parser
+ (car (treesit-local-parsers-at
+ pos parser-or-lang))))
(treesit-parser-root-node parser))
(treesit-buffer-root-node
- (or parser-or-lang lang-at-point)))))
+ (or parser-or-lang
+ (treesit-language-at pos))))))
(node root)
(node-before root)
(pos-1 (max (1- pos) (point-min)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 93a458f25f2: Fix treesit-node-at wrt local parsers,
Yuan Fu <=