1
0

Add Fold: Toggle Fold command

This commit is contained in:
Zef Hemel 2023-06-17 09:01:32 +02:00
parent 5f1f02e8b9
commit eefd8a5245
5 changed files with 19 additions and 0 deletions

View File

@ -94,6 +94,7 @@ export {
StreamLanguage, StreamLanguage,
syntaxHighlighting, syntaxHighlighting,
syntaxTree, syntaxTree,
toggleFold,
unfoldAll, unfoldAll,
unfoldCode, unfoldCode,
} from "@codemirror/language"; } from "@codemirror/language";

View File

@ -139,6 +139,10 @@ export function unfold() {
return syscall("editor.unfold"); return syscall("editor.unfold");
} }
export function toggleFold() {
return syscall("editor.toggleFold");
}
export function foldAll() { export function foldAll() {
return syscall("editor.foldAll"); return syscall("editor.foldAll");
} }

View File

@ -382,6 +382,12 @@ functions:
name: "Fold: Unfold" name: "Fold: Unfold"
mac: "Cmd-Alt-]" mac: "Cmd-Alt-]"
key: "Ctrl-Shift-]" key: "Ctrl-Shift-]"
toggleFoldCommand:
path: ./editor.ts:toggleFoldCommand
command:
name: "Fold: Toggle Fold"
mac: "Cmd-Alt-f"
key: "Ctrl-Shift-f"
foldAllCommand: foldAllCommand:
path: ./editor.ts:foldAllCommand path: ./editor.ts:foldAllCommand
command: command:

View File

@ -26,6 +26,10 @@ export async function unfoldCommand() {
await editor.unfold(); await editor.unfold();
} }
export async function toggleFoldCommand() {
await editor.toggleFold();
}
export async function foldAllCommand() { export async function foldAllCommand() {
await editor.foldAll(); await editor.foldAll();
} }

View File

@ -3,6 +3,7 @@ import {
EditorView, EditorView,
foldAll, foldAll,
foldCode, foldCode,
toggleFold,
Transaction, Transaction,
unfoldAll, unfoldAll,
unfoldCode, unfoldCode,
@ -188,6 +189,9 @@ export function editorSyscalls(editor: Editor): SysCallMapping {
"editor.unfold": () => { "editor.unfold": () => {
unfoldCode(editor.editorView!); unfoldCode(editor.editorView!);
}, },
"editor.toggleFold": () => {
toggleFold(editor.editorView!);
},
"editor.foldAll": () => { "editor.foldAll": () => {
foldAll(editor.editorView!); foldAll(editor.editorView!);
}, },