-
Notifications
You must be signed in to change notification settings - Fork 23
Add folding ranges #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add folding ranges #815
Conversation
|
are we good to go? |
|
Let's try this out. When this is ported to Rowan we should also consider a simple loop over an iterator that walks each node in DFS, like this: https://github.com/rust-lang/rust-analyzer/blob/789d9153e4615c63027305299f3a33d933e96464/crates/ide/src/folding_ranges.rs#L52 For nodes you can easily find the ending, and for sections we'd just match the next closing section within the current node. This way we avoid recursing (slower due to function calls, potential for overflow) and we simplify the logic (for instance no need to maintain stacks). Thanks for the contribution! |
|
Thanks for playing ping pong with us @kv9898, sorry again about that! |
Moving back from posit-dev/air#146.
Old description:
It seems that the call for folding ranges has been quite a while: posit-dev/positron#18, posit-dev/positron#2924, posit-dev/positron#3822.
I was initially only thinking about adding foldable comments, but it seems that doing this will disable the existing folding support for things like regions and brackets. Therefore, I rewrote these functionalities also.
The PR already supports the folding-range-handling of brackets, regions, code cells, indentations and nested comment sections:
(The screenshot is new, though)

Note that, compared to the old PR, this PR no longer relies on a naive search for brackets. Instead it uses the new
tree_sitterof air to walk down the AST for node handling.