mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-22 16:22:27 +00:00
Remove special casing in command factory (revert changes in ctx.ts), update main.createCommands instead
This commit is contained in:
parent
92da17cfa5
commit
e2e24f84c4
2 changed files with 3 additions and 12 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue