diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-12-30 16:43:34 +0100 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2019-12-30 19:07:59 +0100 |
| commit | 5aebf1081dced95a71c674aba65fb5b3e40e6ff1 (patch) | |
| tree | bacedf66912eee5a366a3c93c60a39ba29744f92 /editors/code/src/ctx.ts | |
| parent | 83d2527880d86653ce00940c65620319b36afcff (diff) | |
| download | rust-5aebf1081dced95a71c674aba65fb5b3e40e6ff1.tar.gz rust-5aebf1081dced95a71c674aba65fb5b3e40e6ff1.zip | |
Refactor applySourceChange
Diffstat (limited to 'editors/code/src/ctx.ts')
| -rw-r--r-- | editors/code/src/ctx.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 712337fe71c..22af5ef321a 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -27,6 +27,28 @@ export class Ctx { this.pushCleanup(d); } + overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { + const defaultCmd = `default:${name}`; + const override = factory(this); + const original = (...args: any[]) => + vscode.commands.executeCommand(defaultCmd, ...args); + try { + const d = vscode.commands.registerCommand( + name, + async (...args: any[]) => { + if (!(await override(...args))) { + return await original(...args); + } + }, + ); + this.pushCleanup(d); + } catch (_) { + vscode.window.showWarningMessage( + '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', + ); + } + } + pushCleanup(d: { dispose(): any }) { this.extCtx.subscriptions.push(d); } |
