Unnamed repository; edit this file 'description' to name the repository.
Remove special casing in command factory (revert changes in ctx.ts), update main.createCommands instead
Mark Pots 10 months ago
parent 92da17c · commit e2e24f8
-rw-r--r--editors/code/src/ctx.ts13
-rw-r--r--editors/code/src/main.ts2
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<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 },