Closed typhooncamel closed 2 months ago
I think this is likely an issue for https://github.com/r-lib/tree-sitter-r
Using :InspectTree
:
Code formatted with a new line before the else statement's opening brace:
if (TRUE) {
} else
{
}
errors
(program ; [0, 0] - [8, 0]
(if_statement ; [0, 0] - [1, 1]
condition: (true) ; [0, 4] - [0, 8]
consequence: (braced_expression)) ; [0, 10] - [1, 1]
(ERROR ; [1, 2] - [3, 1]
(ERROR))) ; [2, 0] - [3, 1]
Whereas formatted more typically:
if (TRUE) {
} else {
}
gives...
(program ; [0, 0] - [7, 0]
(if_statement ; [0, 0] - [2, 1]
condition: (true) ; [0, 4] - [0, 8]
consequence: (braced_expression) ; [0, 10] - [1, 1]
alternative: (braced_expression))) ; [1, 7] - [2, 1]
I think this was fixed there: https://github.com/r-lib/tree-sitter-r/issues/141
Yep, thanks!
I'm encountering an issue I've not had before. When I have an if/else statement, if the opening curly bracket is on a new line, then the closing bracket is not sent. E.g.,
if I'm on the
if
statement, and send that line, it'll send all subsequent lines, except for the last}
. This is not much of an issue in this specific example, but when these are inside functions, and I try to send the function, it can lead to errors. This happens when I send a single line so that then it automatically tries sending the whole statement/function. If I visually select the function or the if/else statement above and send that, there are no problems. Any idea why?