Implement toggleFold command #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
toggleFoldcommand.The existing
foldCodecommand 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
toggleFoldto theF2key, but I imagine you'll want to change that.Demo: https://codesandbox.io/s/vigorous-hodgkin-lnhrz7?file=/index.ts
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.