[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-m
From: |
Dmitry Gutov |
Subject: |
bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode |
Date: |
Fri, 10 Nov 2023 03:41:00 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
Hi!
On 07/11/2023 16:56, Loïc Lemaître wrote:
Hi Emacs team,
Here the steps to demonstrate the bug :
1. Compile Emacs from master branch with tree-sitter support
2. Install javascript and tsx languages
3. Run Emacs
4. Create a new buffer
5. Turn major mode to either js-ts-mode or tsx-ts-mode
6. Past the following content into the buffer:
(
<div>
</div>
);
7. Place point before opening parenthese
8. M-x forward-sexp (which will call treesit-forward-sexp)
=> New position is right after the semi-colon instead of being before
the semi-colon.
Note that the bug disappear if the buffer content is changed for :
const component = (
<div>
</div>
);
But previous content, while not being very usefull, is valid JSX, as far
as I know.
I use this syntax for unit test purpose, since it is very short.
Thanks for the report.
The patch below should fix it.
Yuan, what do you think? A similar change (bos and eos anchors) might be
useful for other things and other modes.
Alternatively, treesit-thing-settings could be interpreted to imply full
matches, then the code using it should not only match against the
regexps but also check that the entire string (type name) is matched.
Also Cc'ing Theodor.
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index 5a669fdbd42..d81fa9ed322 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3843,6 +3843,7 @@ js--treesit-sexp-nodes
"undefined"
"arguments"
"pair"
+ "parenthesized_expression"
"jsx")
"Nodes that designate sexps in JavaScript.
See `treesit-thing-settings' for more information.")
@@ -3886,7 +3887,7 @@ js-ts-mode
(setq-local treesit-thing-settings
`((javascript
- (sexp ,(regexp-opt js--treesit-sexp-nodes))
+ (sexp ,(format "\\`%s\\'" (regexp-opt
js--treesit-sexp-nodes)))
(sentence ,(regexp-opt js--treesit-sentence-nodes))
(text ,(regexp-opt '("comment"
"template_string"))))))
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Loïc Lemaître, 2023/11/07
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode,
Dmitry Gutov <=
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Juri Linkov, 2023/11/10
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Yuan Fu, 2023/11/10
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Eli Zaretskii, 2023/11/11
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Yuan Fu, 2023/11/15
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Eli Zaretskii, 2023/11/15
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Yuan Fu, 2023/11/18
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Eli Zaretskii, 2023/11/19
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Yuan Fu, 2023/11/19
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Dmitry Gutov, 2023/11/11
- bug#66988: 30.0.50; treesit-forward-sexp not working properly in js-ts-mode and tsx-ts-mode, Yuan Fu, 2023/11/15