Implement toggleFold command #3

Merged
timdown merged 1 commit from main into main 2023-02-02 10:27:33 +01:00
timdown commented 2023-01-31 19:08:43 +01:00 (Migrated from github.com)

One thing that CodeMirror 6 doesn't have that other editors (JetBrains, VS Code, Ace, at least) do is a command to toggle code folding for the current selection. This PR adds a toggleFold command.

The existing foldCode command only works on the first line of the foldable region, so I've added a function to find the innermost foldable region containing a given line.

For want of a widely-used keybinding, I've bound toggleFold to the F2 key, but I imagine you'll want to change that.

Demo: https://codesandbox.io/s/vigorous-hodgkin-lnhrz7?file=/index.ts

One thing that CodeMirror 6 doesn't have that other editors (JetBrains, VS Code, Ace, at least) do is a command to toggle code folding for the current selection. This PR adds a `toggleFold` command. The existing `foldCode` command only works on the first line of the foldable region, so I've added a function to find the innermost foldable region containing a given line. For want of a widely-used keybinding, I've bound `toggleFold` to the `F2` key, but I imagine you'll want to change that. Demo: https://codesandbox.io/s/vigorous-hodgkin-lnhrz7?file=/index.ts
marijnh commented 2023-02-02 10:28:44 +01:00 (Migrated from github.com)

Merged and followed up with 7da7123, which exports the command but removes the keybinding. I wasn't able to find a widely used binding for this, and it seems too obscure to use an F key for. Having the command should make it easy enough to bind your own key to this when desired.

Merged and followed up with 7da7123, which exports the command but removes the keybinding. I wasn't able to find a widely used binding for this, and it seems too obscure to use an F key for. Having the command should make it easy enough to bind your own key to this when desired.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/language!3
No description provided.