aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/commands/on_enter.ts10
-rw-r--r--editors/code/src/ctx.ts24
-rw-r--r--editors/code/src/main.ts3
4 files changed, 1 insertions, 41 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 05f55cb35..421124764 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -167,11 +167,6 @@
167 "default": {}, 167 "default": {},
168 "description": "Fine grained feature flags to disable annoying features" 168 "description": "Fine grained feature flags to disable annoying features"
169 }, 169 },
170 "rust-analyzer.enableEnhancedTyping": {
171 "type": "boolean",
172 "default": false,
173 "description": "Enables enhanced typing. NOTE: If using a VIM extension, you should set this to false"
174 },
175 "rust-analyzer.raLspServerPath": { 170 "rust-analyzer.raLspServerPath": {
176 "type": [ 171 "type": [
177 "string" 172 "string"
diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts
index 1b3d3d741..ac582b423 100644
--- a/editors/code/src/commands/on_enter.ts
+++ b/editors/code/src/commands/on_enter.ts
@@ -26,17 +26,9 @@ async function handleKeypress(ctx: Ctx) {
26 return true; 26 return true;
27} 27}
28 28
29export function onEnterOverride(ctx: Ctx): Cmd {
30 return async (event: { text: string }) => {
31 if (event.text === '\n') {
32 handleKeypress(ctx);
33 }
34 };
35}
36
37export function onEnter(ctx: Ctx): Cmd { 29export function onEnter(ctx: Ctx): Cmd {
38 return async () => { 30 return async () => {
39 if (handleKeypress(ctx)) return; 31 if (await handleKeypress(ctx)) return;
40 32
41 await vscode.commands.executeCommand('default:type', { text: '\n' }); 33 await vscode.commands.executeCommand('default:type', { text: '\n' });
42 }; 34 };
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 05d21ae56..aa75943bf 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -50,30 +50,6 @@ export class Ctx {
50 this.pushCleanup(d); 50 this.pushCleanup(d);
51 } 51 }
52 52
53 overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) {
54 const defaultCmd = `default:${name}`;
55 const override = factory(this);
56 const original = (...args: unknown[]) =>
57 vscode.commands.executeCommand(defaultCmd, ...args);
58 try {
59 const d = vscode.commands.registerCommand(
60 name,
61 async (...args: unknown[]) => {
62 if (!(await override(...args))) {
63 return await original(...args);
64 }
65 },
66 );
67 this.pushCleanup(d);
68 } catch (_) {
69 vscode.window.showWarningMessage(
70 'Enhanced typing feature is disabled because of incompatibility ' +
71 'with VIM extension, consider turning off rust-analyzer.enableEnhancedTyping: ' +
72 'https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/README.md#settings',
73 );
74 }
75 }
76
77 get subscriptions(): Disposable[] { 53 get subscriptions(): Disposable[] {
78 return this.extCtx.subscriptions; 54 return this.extCtx.subscriptions;
79 } 55 }
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 5c061e72f..efc31b2e2 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -29,9 +29,6 @@ export async function activate(context: vscode.ExtensionContext) {
29 ctx.registerCommand('applySourceChange', commands.applySourceChange); 29 ctx.registerCommand('applySourceChange', commands.applySourceChange);
30 ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange); 30 ctx.registerCommand('selectAndApplySourceChange', commands.selectAndApplySourceChange);
31 31
32 if (ctx.config.enableEnhancedTyping) {
33 ctx.overrideCommand('type', commands.onEnterOverride);
34 }
35 activateStatusDisplay(ctx); 32 activateStatusDisplay(ctx);
36 33
37 activateHighlighting(ctx); 34 activateHighlighting(ctx);