about summary refs log tree commit diff
path: root/src/tools/rust-analyzer/editors/code
diff options
context:
space:
mode:
authorMark Pots <mpots@dat.nl>2025-06-24 11:56:22 +0200
committerMark Pots <mpots@dat.nl>2025-06-24 11:56:22 +0200
commit7eb776e22eff6704df27c7023f289ef04fec12d7 (patch)
treef392b55d043e8aed6c066425bf344cae4597df74 /src/tools/rust-analyzer/editors/code
parent98e7b944fcbf1439d9f99581ea35f37760e02aa9 (diff)
downloadrust-7eb776e22eff6704df27c7023f289ef04fec12d7.tar.gz
rust-7eb776e22eff6704df27c7023f289ef04fec12d7.zip
Remove special casing in command factory (revert changes in ctx.ts), update main.createCommands instead
Diffstat (limited to 'src/tools/rust-analyzer/editors/code')
-rw-r--r--src/tools/rust-analyzer/editors/code/src/ctx.ts13
-rw-r--r--src/tools/rust-analyzer/editors/code/src/main.ts2
2 files changed, 3 insertions, 12 deletions
diff --git a/src/tools/rust-analyzer/editors/code/src/ctx.ts b/src/tools/rust-analyzer/editors/code/src/ctx.ts
index 0fb0a1f17cb..e55754fb9f0 100644
--- a/src/tools/rust-analyzer/editors/code/src/ctx.ts
+++ b/src/tools/rust-analyzer/editors/code/src/ctx.ts
@@ -1,7 +1,6 @@
 import * as vscode from "vscode";
 import type * as lc from "vscode-languageclient/node";
 import * as ra from "./lsp_ext";
-import * as commands from "./commands";
 
 import { Config, prepareVSCodeConfig } from "./config";
 import { createClient } from "./client";
@@ -463,17 +462,9 @@ export class Ctx implements RustAnalyzerExtensionApi {
         for (const [name, factory] of Object.entries(this.commandFactories)) {
             const fullName = `rust-analyzer.${name}`;
             let callback;
-
             if (isClientRunning(this)) {
-                if (name === "run") {
-                    // Special case: support optional argument for `run`
-                    callback = (mode?: "cursor") => {
-                        return commands.run(this, mode)();
-                    };
-                } else {
-                    // we asserted that `client` is defined
-                    callback = factory.enabled(this);
-                }
+                // we asserted that `client` is defined
+                callback = factory.enabled(this);
             } else if (factory.disabled) {
                 callback = factory.disabled(this);
             } else {
diff --git a/src/tools/rust-analyzer/editors/code/src/main.ts b/src/tools/rust-analyzer/editors/code/src/main.ts
index 5e500730693..996298524f1 100644
--- a/src/tools/rust-analyzer/editors/code/src/main.ts
+++ b/src/tools/rust-analyzer/editors/code/src/main.ts
@@ -167,7 +167,7 @@ function createCommands(): Record<string, CommandFactory> {
         viewCrateGraph: { enabled: commands.viewCrateGraph },
         viewFullCrateGraph: { enabled: commands.viewFullCrateGraph },
         expandMacro: { enabled: commands.expandMacro },
-        run: { enabled: commands.run },
+        run: { enabled: (ctx) => (mode?: "cursor") => commands.run(ctx, mode)() },
         copyRunCommandLine: { enabled: commands.copyRunCommandLine },
         debug: { enabled: commands.debug },
         newDebugConfig: { enabled: commands.newDebugConfig },