-
Notifications
You must be signed in to change notification settings - Fork 14
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 nested outline to refactored code #611
Add nested outline to refactored code #611
Conversation
Moved to here as #606 was accidentally closed. |
Hi @kv9898. Could you take a look at the changes I've made? I kept your general outline of the algorithm but I've simplified the way we manage the section stack. I've also added a test using |
The changes look great! I was surprised by the snapshot test - must have been a big effort! I noted that two of the tests failed, but it seemed that they were unrelated to our changes, right? I also noted that when using the nightly Rust (I tried with 1.84 on Windows), the ark kernel keeps crashing after 1 second or so. I (not the programme) panicked about some potential fatal errors I wrote. Things have been good with 1.80. As a side note, do you have any suggestions on the implementation of the folding range functionality? It seems that once we initiate the Folding Range Capability, other folding rules are overridden (i.e. we need to cover all existing folding rules to prevent a regression). I'm thinking of using the same node-walking strategy to create foldable comment sections, but I'm not sure whether I can reuse any |
Luckily very easy, I switched to using https://docs.rs/insta/latest/insta/ to generate the snapshot from the
These failures are from #609
I think node walking would be a good strategy for folding ranges too. The ranges will be nested and this nesting is consistent with the nesting of the syntax tree. I guess there are two options:
Note that we'll change the representation of the syntax tree in the coming weeks to https://github.com/rust-analyzer/rowan. Don't worry about implementing new code with Tree-sitter, just be aware that at some point this code will have to be rewritten. The TS and rowan representations will coexist for some time so there won't be any rush to switch. But I think this tells me that we can keep things simple for the folding range algorithm, i.e. have a separate traversal. Make a good set of tests for it. And then when we rewrite these to use the new representation we can think about merging them. But if you see a simple way to colect folding ranges in the symbol traversal, feel free to go for it! In either case it's probably best to start small. Since implementing folding ranges disables the existing rules we have, maybe this could be implemented under a feature flag that's disabled by default. This would allow you to implement incrementally with simple PRs. |
Thanks for your work on this! |
Should solve the majority of posit-dev/positron#3822 except for the foldable comment sections.
Also replace
OBJECT
s in tests withVARIABLE
s.With code:
The outline with the refactored code now looks like: