Skip to content

Commit

Permalink
Merge #322
Browse files Browse the repository at this point in the history
322: Fix analyzer extension fail when there are enabled any VIM extension r=matklad a=max-frai

`type` command is allowed only once to be registered and it was built specially for vim mode.
So if user has vim extension enabled, rust-analyzer initialization failes on trying to register own `type` handler.

Unfortunatelly, there are no nice ways to check if command is already registered so the way is to wrap everything with try/catch and notify user about conflict.

Co-authored-by: frai <[email protected]>
  • Loading branch information
bors[bot] and max-frai committed Dec 22, 2018
2 parents 5c7e8f4 + 0f5d9a0 commit 5a5402d
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions editors/code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ export function activate(context: vscode.ExtensionContext) {
const original = (...args: any[]) =>
vscode.commands.executeCommand(defaultCmd, ...args);

registerCommand(name, async (...args: any[]) => {
const editor = vscode.window.activeTextEditor;
if (
!editor ||
!editor.document ||
editor.document.languageId !== 'rust'
) {
return await original(...args);
}
if (!(await f(...args))) {
return await original(...args);
}
});
try {
registerCommand(name, async (...args: any[]) => {
const editor = vscode.window.activeTextEditor;
if (
!editor ||
!editor.document ||
editor.document.languageId !== 'rust'
) {
return await original(...args);
}
if (!(await f(...args))) {
return await original(...args);
}
});
} catch(_) {
vscode.window.showWarningMessage('Enhanced typing feature is disabled because of incompatibility with VIM extension');
}
}

// Commands are requests from vscode to the language server
Expand Down

0 comments on commit 5a5402d

Please sign in to comment.