Skip to content

Commit 7eb776e

Browse files
committed
Remove special casing in command factory (revert changes in ctx.ts), update main.createCommands instead
1 parent 98e7b94 commit 7eb776e

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/tools/rust-analyzer/editors/code/src/ctx.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from "vscode";
22
import type * as lc from "vscode-languageclient/node";
33
import * as ra from "./lsp_ext";
4-
import * as commands from "./commands";
54

65
import { Config, prepareVSCodeConfig } from "./config";
76
import { createClient } from "./client";
@@ -463,17 +462,9 @@ export class Ctx implements RustAnalyzerExtensionApi {
463462
for (const [name, factory] of Object.entries(this.commandFactories)) {
464463
const fullName = `rust-analyzer.${name}`;
465464
let callback;
466-
467465
if (isClientRunning(this)) {
468-
if (name === "run") {
469-
// Special case: support optional argument for `run`
470-
callback = (mode?: "cursor") => {
471-
return commands.run(this, mode)();
472-
};
473-
} else {
474-
// we asserted that `client` is defined
475-
callback = factory.enabled(this);
476-
}
466+
// we asserted that `client` is defined
467+
callback = factory.enabled(this);
477468
} else if (factory.disabled) {
478469
callback = factory.disabled(this);
479470
} else {

src/tools/rust-analyzer/editors/code/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function createCommands(): Record<string, CommandFactory> {
167167
viewCrateGraph: { enabled: commands.viewCrateGraph },
168168
viewFullCrateGraph: { enabled: commands.viewFullCrateGraph },
169169
expandMacro: { enabled: commands.expandMacro },
170-
run: { enabled: commands.run },
170+
run: { enabled: (ctx) => (mode?: "cursor") => commands.run(ctx, mode)() },
171171
copyRunCommandLine: { enabled: commands.copyRunCommandLine },
172172
debug: { enabled: commands.debug },
173173
newDebugConfig: { enabled: commands.newDebugConfig },

0 commit comments

Comments
 (0)