755: Add new configuration "enableEnhancedTyping" to control registering of "type" command r=matklad a=vipentti

This further fixes problems when having a VIM extension (at least vscodevim)
enabled, by not calling `overrideCommand('type', commands.onEnter.handle)` when
enableEnhancedTyping is set to `false`.

The problem is dependent on the order in which extensions are activated, if
rust-analyzer is activated before `vscodevim`, rust-analyzer will register the
`type` command, and when `vscodevim` finally attempts to activate, it will fail
to register the command. This causes `vscodevim` to stop working properly.

This setting allows users to disable the registerCommand `type` in
rust-analyzer, allowing `vscodevim` to work. The setting defaults to `true`.

Currently changing the setting requires reloading of the window.

Co-authored-by: Ville Penttinen <villem.penttinen@gmail.com>
This commit is contained in:
bors[bot] 2019-02-07 12:42:53 +00:00
commit d0fd05142f
3 changed files with 40 additions and 1 deletions

View file

@ -150,6 +150,11 @@
"default": true, "default": true,
"description": "Highlight Rust code (overrides built-in syntax highlighting)" "description": "Highlight Rust code (overrides built-in syntax highlighting)"
}, },
"rust-analyzer.enableEnhancedTyping": {
"type": "boolean",
"default": true,
"description": "Enables enhanced typing. NOTE: If using a VIM extension, you should set this to false"
},
"rust-analyzer.raLspServerPath": { "rust-analyzer.raLspServerPath": {
"type": [ "type": [
"string" "string"

View file

@ -6,8 +6,11 @@ const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
export class Config { export class Config {
public highlightingOn = true; public highlightingOn = true;
public enableEnhancedTyping = true;
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
private prevEnhancedTyping: null | boolean = null;
constructor() { constructor() {
vscode.workspace.onDidChangeConfiguration(_ => vscode.workspace.onDidChangeConfiguration(_ =>
this.userConfigChanged() this.userConfigChanged()
@ -25,6 +28,35 @@ export class Config {
Server.highlighter.removeHighlights(); Server.highlighter.removeHighlights();
} }
if (config.has('enableEnhancedTyping')) {
this.enableEnhancedTyping = config.get(
'enableEnhancedTyping'
) as boolean;
if (this.prevEnhancedTyping === null) {
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
} else if (this.prevEnhancedTyping === null) {
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
if (this.prevEnhancedTyping !== this.enableEnhancedTyping) {
const reloadAction = 'Reload now';
vscode.window
.showInformationMessage(
'Changing enhanced typing setting requires a reload',
reloadAction
)
.then(selectedAction => {
if (selectedAction === reloadAction) {
vscode.commands.executeCommand(
'workbench.action.reloadWindow'
);
}
});
this.prevEnhancedTyping = this.enableEnhancedTyping;
}
if (config.has('raLspServerPath')) { if (config.has('raLspServerPath')) {
this.raLspServerPath = this.raLspServerPath =
RA_LSP_DEBUG || (config.get('raLspServerPath') as string); RA_LSP_DEBUG || (config.get('raLspServerPath') as string);

View file

@ -82,7 +82,9 @@ export function activate(context: vscode.ExtensionContext) {
} }
); );
overrideCommand('type', commands.onEnter.handle); if (Server.config.enableEnhancedTyping) {
overrideCommand('type', commands.onEnter.handle);
}
// Notifications are events triggered by the language server // Notifications are events triggered by the language server
const allNotifications: Iterable< const allNotifications: Iterable<