From e2e24f84c46c48573d5b0a728a24b826f5e3abbc Mon Sep 17 00:00:00 2001 From: Mark Pots Date: Tue, 24 Jun 2025 11:56:22 +0200 Subject: [PATCH] Remove special casing in command factory (revert changes in ctx.ts), update main.createCommands instead --- editors/code/src/ctx.ts | 13 ++----------- editors/code/src/main.ts | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 0fb0a1f17c..e55754fb9f 100644 --- a/editors/code/src/ctx.ts +++ b/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/editors/code/src/main.ts b/editors/code/src/main.ts index 5e50073069..996298524f 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -167,7 +167,7 @@ function createCommands(): Record { 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 },