-
-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Labels
Description
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-typescript
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
No response
Describe the bug
Using this code:
const me = 'me';
const you = 'you';
const a = `Hello ${me} and ${you} and ${you} again`;and this query:
(template_string (template_substitution)* @sub) @tagged_template
I am expecting that tagged_template would have 3 captures with name as sub but instead it has only 1.
Easily reproducible in the Playground:
Notice only the first template parameter is highlighted.
Steps To Reproduce/Bad Parse Tree
const me = 'me';
const you = 'you';
const a = `Hello ${me} and ${you} and ${you} again`;Which gives this parse tree:
program [0, 0] - [3, 0]
lexical_declaration [0, 0] - [0, 16]
variable_declarator [0, 6] - [0, 15]
name: identifier [0, 6] - [0, 8]
value: string [0, 11] - [0, 15]
string_fragment [0, 12] - [0, 14]
lexical_declaration [1, 0] - [1, 18]
variable_declarator [1, 6] - [1, 17]
name: identifier [1, 6] - [1, 9]
value: string [1, 12] - [1, 17]
string_fragment [1, 13] - [1, 16]
lexical_declaration [2, 0] - [2, 52]
variable_declarator [2, 6] - [2, 51]
name: identifier [2, 6] - [2, 7]
value: template_string [2, 10] - [2, 51]
string_fragment [2, 11] - [2, 17]
template_substitution [2, 17] - [2, 22]
identifier [2, 19] - [2, 21]
string_fragment [2, 22] - [2, 27]
template_substitution [2, 27] - [2, 33]
identifier [2, 29] - [2, 32]
string_fragment [2, 33] - [2, 38]
template_substitution [2, 38] - [2, 44]
identifier [2, 40] - [2, 43]
string_fragment [2, 44] - [2, 50]
and this query:
(template_string (template_substitution)* @sub) @tagged_template
only captures the first template_substitution
Expected Behavior/Parse Tree
The query result should contain all of the template_substitutions
Repro
const me = 'me';
const you = 'you';
const a = `Hello ${me} and ${you} and ${you} again`;