Add context to all show-panel invocations
parent
7c926e59c6
commit
ef4f6ad171
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue