mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
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 <aleksey.kladov@gmail.com>
This commit is contained in:
commit
dc6383c422
@ -12,6 +12,26 @@ import { log } from './util';
|
||||
let ctx: Ctx | undefined;
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
// Register a "dumb" onEnter command for the case where server fails to
|
||||
// start.
|
||||
//
|
||||
// FIXME: refactor command registration code such that commands are
|
||||
// **always** registered, even if the server does not start. Use API like
|
||||
// this perhaps?
|
||||
//
|
||||
// ```TypeScript
|
||||
// registerCommand(
|
||||
// factory: (Ctx) => ((Ctx) => any),
|
||||
// fallback: () => any = () => vscode.window.showErrorMessage(
|
||||
// "rust-analyzer is not available"
|
||||
// ),
|
||||
// )
|
||||
const defaultOnEnter = vscode.commands.registerCommand(
|
||||
'rust-analyzer.onEnter',
|
||||
() => vscode.commands.executeCommand('default:type', { text: '\n' }),
|
||||
);
|
||||
context.subscriptions.push(defaultOnEnter);
|
||||
|
||||
const config = new Config(context);
|
||||
|
||||
const serverPath = await ensureServerBinary(config.serverSource);
|
||||
@ -54,7 +74,10 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
ctx.registerCommand('syntaxTree', commands.syntaxTree);
|
||||
ctx.registerCommand('expandMacro', commands.expandMacro);
|
||||
ctx.registerCommand('run', commands.run);
|
||||
|
||||
defaultOnEnter.dispose();
|
||||
ctx.registerCommand('onEnter', commands.onEnter);
|
||||
|
||||
ctx.registerCommand('ssr', commands.ssr);
|
||||
ctx.registerCommand('serverVersion', commands.serverVersion);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user