Skip to content

Commit d0fd051

Browse files
bors[bot]vipentti
andcommitted
Merge #755
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 <[email protected]>
2 parents a69ee77 + a4d0aeb commit d0fd051

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

editors/code/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
"default": true,
151151
"description": "Highlight Rust code (overrides built-in syntax highlighting)"
152152
},
153+
"rust-analyzer.enableEnhancedTyping": {
154+
"type": "boolean",
155+
"default": true,
156+
"description": "Enables enhanced typing. NOTE: If using a VIM extension, you should set this to false"
157+
},
153158
"rust-analyzer.raLspServerPath": {
154159
"type": [
155160
"string"

editors/code/src/config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG;
66

77
export class Config {
88
public highlightingOn = true;
9+
public enableEnhancedTyping = true;
910
public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server';
1011

12+
private prevEnhancedTyping: null | boolean = null;
13+
1114
constructor() {
1215
vscode.workspace.onDidChangeConfiguration(_ =>
1316
this.userConfigChanged()
@@ -25,6 +28,35 @@ export class Config {
2528
Server.highlighter.removeHighlights();
2629
}
2730

31+
if (config.has('enableEnhancedTyping')) {
32+
this.enableEnhancedTyping = config.get(
33+
'enableEnhancedTyping'
34+
) as boolean;
35+
36+
if (this.prevEnhancedTyping === null) {
37+
this.prevEnhancedTyping = this.enableEnhancedTyping;
38+
}
39+
} else if (this.prevEnhancedTyping === null) {
40+
this.prevEnhancedTyping = this.enableEnhancedTyping;
41+
}
42+
43+
if (this.prevEnhancedTyping !== this.enableEnhancedTyping) {
44+
const reloadAction = 'Reload now';
45+
vscode.window
46+
.showInformationMessage(
47+
'Changing enhanced typing setting requires a reload',
48+
reloadAction
49+
)
50+
.then(selectedAction => {
51+
if (selectedAction === reloadAction) {
52+
vscode.commands.executeCommand(
53+
'workbench.action.reloadWindow'
54+
);
55+
}
56+
});
57+
this.prevEnhancedTyping = this.enableEnhancedTyping;
58+
}
59+
2860
if (config.has('raLspServerPath')) {
2961
this.raLspServerPath =
3062
RA_LSP_DEBUG || (config.get('raLspServerPath') as string);

editors/code/src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export function activate(context: vscode.ExtensionContext) {
8282
}
8383
);
8484

85-
overrideCommand('type', commands.onEnter.handle);
85+
if (Server.config.enableEnhancedTyping) {
86+
overrideCommand('type', commands.onEnter.handle);
87+
}
8688

8789
// Notifications are events triggered by the language server
8890
const allNotifications: Iterable<

0 commit comments

Comments
 (0)