aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-24 11:33:00 +0000
committerGitHub <[email protected]>2020-02-24 11:33:00 +0000
commitdc6383c42237fc46c0955d15ae2d13e7f3527635 (patch)
tree276c350d7a3d36564d1bcd6a70bb3abb57fe00e9 /editors
parent1d1c1b0d85547d31775f9e0f3b5516c4b38fed9f (diff)
parentb12cbd60628b6061649c3d41bc8d7022c75aa362 (diff)
Merge #3289
3289: Don't break onEnter if rust-analyzer fails to start r=matklad a=matklad closes #3253 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/main.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 7b3bb6302..424ff1ac3 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -12,6 +12,26 @@ import { log } from './util';
12let ctx: Ctx | undefined; 12let ctx: Ctx | undefined;
13 13
14export async function activate(context: vscode.ExtensionContext) { 14export async function activate(context: vscode.ExtensionContext) {
15 // Register a "dumb" onEnter command for the case where server fails to
16 // start.
17 //
18 // FIXME: refactor command registration code such that commands are
19 // **always** registered, even if the server does not start. Use API like
20 // this perhaps?
21 //
22 // ```TypeScript
23 // registerCommand(
24 // factory: (Ctx) => ((Ctx) => any),
25 // fallback: () => any = () => vscode.window.showErrorMessage(
26 // "rust-analyzer is not available"
27 // ),
28 // )
29 const defaultOnEnter = vscode.commands.registerCommand(
30 'rust-analyzer.onEnter',
31 () => vscode.commands.executeCommand('default:type', { text: '\n' }),
32 );
33 context.subscriptions.push(defaultOnEnter);
34
15 const config = new Config(context); 35 const config = new Config(context);
16 36
17 const serverPath = await ensureServerBinary(config.serverSource); 37 const serverPath = await ensureServerBinary(config.serverSource);
@@ -54,7 +74,10 @@ export async function activate(context: vscode.ExtensionContext) {
54 ctx.registerCommand('syntaxTree', commands.syntaxTree); 74 ctx.registerCommand('syntaxTree', commands.syntaxTree);
55 ctx.registerCommand('expandMacro', commands.expandMacro); 75 ctx.registerCommand('expandMacro', commands.expandMacro);
56 ctx.registerCommand('run', commands.run); 76 ctx.registerCommand('run', commands.run);
77
78 defaultOnEnter.dispose();
57 ctx.registerCommand('onEnter', commands.onEnter); 79 ctx.registerCommand('onEnter', commands.onEnter);
80
58 ctx.registerCommand('ssr', commands.ssr); 81 ctx.registerCommand('ssr', commands.ssr);
59 ctx.registerCommand('serverVersion', commands.serverVersion); 82 ctx.registerCommand('serverVersion', commands.serverVersion);
60 83