Add context to all show-panel invocations

pull/211/head
Zef Hemel 2022-12-16 16:35:05 +01:00
parent 7c926e59c6
commit ef4f6ad171
1 changed files with 4 additions and 4 deletions

View File

@ -227,7 +227,7 @@ export class Editor {
if (ev.touches.length > 2) { if (ev.touches.length > 2) {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
this.viewDispatch({ type: "show-palette" }); this.viewDispatch({ type: "show-palette", context: this.getContext() });
} }
}); });
} }
@ -889,7 +889,7 @@ export class Editor {
icon: TerminalIcon, icon: TerminalIcon,
description: `Run command (${isMacLike() ? "Cmd-/" : "Ctrl-/"})`, description: `Run command (${isMacLike() ? "Cmd-/" : "Ctrl-/"})`,
callback: () => { 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); const cmd = this.viewState.commands.get(name);
if (cmd) { if (cmd) {
await cmd.run(); await cmd.run();
@ -965,7 +965,7 @@ export class Editor {
const state = this.editorView!.state; const state = this.editorView!.state;
const selection = state.selection.main; const selection = state.selection.main;
if (selection.empty) { if (selection.empty) {
return syntaxTree(state).resolveInner(selection.from).name; return syntaxTree(state).resolveInner(selection.from).type.name;
} }
return; return;
} }