aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 712337fe7..22af5ef32 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -27,6 +27,28 @@ export class Ctx {
27 this.pushCleanup(d); 27 this.pushCleanup(d);
28 } 28 }
29 29
30 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) {
31 const defaultCmd = `default:${name}`;
32 const override = factory(this);
33 const original = (...args: any[]) =>
34 vscode.commands.executeCommand(defaultCmd, ...args);
35 try {
36 const d = vscode.commands.registerCommand(
37 name,
38 async (...args: any[]) => {
39 if (!(await override(...args))) {
40 return await original(...args);
41 }
42 },
43 );
44 this.pushCleanup(d);
45 } catch (_) {
46 vscode.window.showWarningMessage(
47 'Enhanced typing feature is disabled because of incompatibility with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
48 );
49 }
50 }
51
30 pushCleanup(d: { dispose(): any }) { 52 pushCleanup(d: { dispose(): any }) {
31 this.extCtx.subscriptions.push(d); 53 this.extCtx.subscriptions.push(d);
32 } 54 }