-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Labels
bugSomething isn't workingSomething isn't working
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
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
tree-sitter 0.25.10 (da6fe9beb4f7f67beb75914ca8e0d48ae48d6406)
Describe the bug
Comments inside a function are not treated as part of the function body.
function strange()
-- Comment
local test = true
endI am not sure whether this is a bug or a deliberate design choice due to my limited knowledge. I noticed this behavior while using the @function.inner capture provided by nvim-treesitter-textobjects (see lua/queries/textobjects.scm).
In the case of lua-language-server, a function description (via a comment) is defined above it, which makes me expect comments inside the function to be considered part of the function body.
Steps To Reproduce/Bad Parse Tree
(chunk [0, 0] - [4, 0]
(function_declaration [0, 0] - [3, 3]
name: (identifier [0, 9] - [0, 16])
parameters: (parameters [0, 16] - [0, 18])
(comment [1, 2] - [1, 12]
content: (comment_content [1, 4] - [1, 12]))
body: (block [2, 2] - [2, 19]
local_declaration: (variable_declaration [2, 2] - [2, 19]
(assignment_statement [2, 8] - [2, 19]
(variable_list [2, 8] - [2, 12]
name: (identifier [2, 8] - [2, 12]))
(expression_list [2, 15] - [2, 19]
value: (true [2, 15] - [2, 19])))))))
Expected Behavior/Parse Tree
(chunk [0, 0] - [4, 0]
(function_declaration [0, 0] - [3, 3]
name: (identifier [0, 9] - [0, 16])
parameters: (parameters [0, 16] - [0, 18])
body: (block [2, 2] - [2, 19]
(comment [1, 2] - [1, 12]
content: (comment_content [1, 4] - [1, 12]))
local_declaration: (variable_declaration [2, 2] - [2, 19]
(assignment_statement [2, 8] - [2, 19]
(variable_list [2, 8] - [2, 12]
name: (identifier [2, 8] - [2, 12]))
(expression_list [2, 15] - [2, 19]
value: (true [2, 15] - [2, 19])))))))
Repro
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working