From ef4f6ad1715a01be7adff0c4256b1075e203bc53 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 16 Dec 2022 16:35:05 +0100 Subject: [PATCH] Add context to all show-panel invocations --- web/editor.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/editor.tsx b/web/editor.tsx index 4efc74bc..abfbd939 100644 --- a/web/editor.tsx +++ b/web/editor.tsx @@ -227,7 +227,7 @@ export class Editor { if (ev.touches.length > 2) { ev.stopPropagation(); ev.preventDefault(); - this.viewDispatch({ type: "show-palette" }); + this.viewDispatch({ type: "show-palette", context: this.getContext() }); } }); } @@ -889,7 +889,7 @@ export class Editor { icon: TerminalIcon, description: `Run command (${isMacLike() ? "Cmd-/" : "Ctrl-/"})`, callback: () => { - dispatch({ type: "show-palette" }); + dispatch({ type: "show-palette", context: this.getContext() }); }, }, { @@ -946,7 +946,7 @@ export class Editor { ); } - async runCommandByName(name: string) { + async runCommandByName(name: string, ...args: any[]) { const cmd = this.viewState.commands.get(name); if (cmd) { await cmd.run(); @@ -965,7 +965,7 @@ export class Editor { const state = this.editorView!.state; const selection = state.selection.main; if (selection.empty) { - return syntaxTree(state).resolveInner(selection.from).name; + return syntaxTree(state).resolveInner(selection.from).type.name; } return; }