posit-dev / ark

Ark, an R kernel
MIT License
179 stars 15 forks source link

Folding Range LSP support #615

Open kv9898 opened 1 month ago

kv9898 commented 1 month ago

It seems that the call for folding ranges has been quite a while: https://github.com/posit-dev/positron/issues/18, https://github.com/posit-dev/positron/issues/2924, https://github.com/posit-dev/positron/issues/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 and nested comment sections:

image

For the handling of regions and code cells, I'm currently implementing a simple lookup of regex, which respects the existing behaviour and disregards any nested structures. I note that this kinds of get messy when you are also using the nested comments. But maybe that's a separate issue?

kv9898 commented 2 weeks ago

@lionel- is there anything else I can help to do?

lionel- commented 2 weeks ago

@kv9898 We just need to get some time to look at this. Probably next week.

kv9898 commented 2 weeks ago

@kv9898 We just need to get some time to look at this. Probably next week.

Thank you! I was worried that you were working on some breaking changes that would cause a merge conflict. It's a little bit difficult to rebase everything at this stage.😄