You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Naively folding each (if_statement) would create a nested fold for each else if, resulting in deeply nested folds. What user would want is to have fold for each body of else if.
Describe the solution you'd like
The entire if-else if-else should be parsed as flat list. Something like this:
(if_statement
(alternative (condition) (consequence)) ; the first `if`
(alternative (condition) (consequence)) ; the first `else if`
(alternative (condition) (consequence)) ; the second `else if`
...
(else (consequence)) ; `else`
)
Did you check the tree-sitter docs?
Is your feature request related to a problem? Please describe.
Currently,
else if
blocks are parsed as nestedif
statements. For example,This structure is suboptimal for various reasons.
If the source contains very long
else if
chain, and a query pattern has a (editor-specific) predicate that climbs up the tree, processing the predicate can be very slow. For example, Neovim's#has-ancestor?
predicate can be slow: Poor performance with Treesitter highlighting on deep if-else in c neovim/neovim#24965.Naively folding each
(if_statement)
would create a nested fold for eachelse if
, resulting in deeply nested folds. What user would want is to have fold for each body ofelse if
.Describe the solution you'd like
The entire
if
-else if
-else
should be parsed as flat list. Something like this:Describe alternatives you've considered
has-ancestor?
for highlighter neovim/neovim#27783. Other solutions: Poor performance with Treesitter highlighting on deep if-else in c neovim/neovim#24965 (comment)consequence: (compound_statement)
instead ofif_statement
.Additional context
No response
The text was updated successfully, but these errors were encountered: