posit-dev / positron

Positron, a next-generation data science IDE
Other
2.31k stars 68 forks source link

ark: Implement folding rules #18

Open kevinushey opened 1 year ago

kevinushey commented 1 year ago

VSCode allows an extension to declare folding rules within language-configuration.json:

https://code.visualstudio.com/api/language-extensions/language-configuration-guide#folding

However, it's fairly rigid -- each foldable region must have separate (and uniquely-matched) start and end boundaries. However, we'd likely want to support foldable sections -- for example:

# Section 1 ----

## Section 1.1 ----

## Section 1.2 ----

For that reason, we'll probably need to implement folding rules in the LSP (unless we want to patch the VSCode behavior here)

kevinushey commented 1 year ago

This probably isn't necessary for MVP, if we want to defer this to later.

EmilHvitfeldt commented 11 months ago

Since we are having quarto support, it would be nice if the folding rules also worked with fenced divs: https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans

In the following picture, it would be neat if line 19-23 could collapse, 26-30 could collapse and 17-32 could collapse

Screenshot 2023-09-27 at 10 46 24 AM

For clarity, i made the outside div with 4 colons, but that isn't strictly needed by quarto, so the columns work on a first-in-first-out kinda basis when they are created with the same number of colons

petetronic commented 9 months ago

Here is RStudio IDE's guide to Code Sections: https://docs.posit.co/ide/user/ide/guide/code/code-sections.html#code-sections @kevinushey was this the functionality you had in mind?

petetronic commented 9 months ago

We recently discussed modifying the newly added positron-code-cells extension to allow runtimes to better control code ranges and behaviors. However, we've not yet prioritized this work.

petetronic commented 9 months ago

Since we are having quarto support, it would be nice if the folding rules also worked with fenced divs: https://quarto.org/docs/authoring/markdown-basics.html#divs-and-spans

In the following picture, it would be neat if line 19-23 could collapse, 26-30 could collapse and 17-32 could collapse

Hi @EmilHvitfeldt, for Quarto docs, the folding rules would be controlled by the Quarto extension. Would you mind logging that request with their backlog here? https://github.com/quarto-dev/quarto/issues

EmilHvitfeldt commented 7 months ago

another use-case here is being able to fold test_that() blocks in R package tests, (missing this one right now). May be related to https://github.com/posit-dev/positron/issues/1428.

juliasilge commented 3 months ago

Requested by a private beta user here: https://github.com/posit-dev/positron-beta/discussions/208