From 77a4a311fe22ac3b786378c452ab0f60e289cf87 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Thu, 7 Feb 2019 12:37:36 +0200 Subject: Add new configuration "enableEnhancedTyping" to control registering of "type" command 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. --- editors/code/src/config.ts | 25 +++++++++++++++++++++++++ editors/code/src/extension.ts | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index d26f5df0a..d49917c78 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -6,8 +6,11 @@ const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; export class Config { public highlightingOn = true; + public enableEnhancedTyping = true; public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; + private prevEnhancedTyping: null | boolean = null; + constructor() { vscode.workspace.onDidChangeConfiguration(_ => this.userConfigChanged() @@ -25,6 +28,28 @@ export class Config { 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')) { this.raLspServerPath = RA_LSP_DEBUG || (config.get('raLspServerPath') as string); diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index a0be70202..8b332eeb2 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -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 const allNotifications: Iterable< -- cgit v1.2.3 From a4d0aebcb89367d23600d0f14ba2c7f1cd0bbb44 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Thu, 7 Feb 2019 12:54:41 +0200 Subject: Run prettier --- editors/code/src/config.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index d49917c78..4e353798c 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -29,7 +29,9 @@ export class Config { } if (config.has('enableEnhancedTyping')) { - this.enableEnhancedTyping = config.get('enableEnhancedTyping') as boolean; + this.enableEnhancedTyping = config.get( + 'enableEnhancedTyping' + ) as boolean; if (this.prevEnhancedTyping === null) { this.prevEnhancedTyping = this.enableEnhancedTyping; @@ -40,16 +42,21 @@ export class Config { if (this.prevEnhancedTyping !== this.enableEnhancedTyping) { const reloadAction = 'Reload now'; - vscode.window.showInformationMessage('Changing enhanced typing setting requires a reload', reloadAction) + vscode.window + .showInformationMessage( + 'Changing enhanced typing setting requires a reload', + reloadAction + ) .then(selectedAction => { if (selectedAction === reloadAction) { - vscode.commands.executeCommand('workbench.action.reloadWindow'); + vscode.commands.executeCommand( + 'workbench.action.reloadWindow' + ); } }); this.prevEnhancedTyping = this.enableEnhancedTyping; } - if (config.has('raLspServerPath')) { this.raLspServerPath = RA_LSP_DEBUG || (config.get('raLspServerPath') as string); -- cgit v1.2.3