Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/ctx.ts')
| -rw-r--r-- | editors/code/src/ctx.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index e55754fb9f..0fb0a1f17c 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -1,6 +1,7 @@ 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"; @@ -462,9 +463,17 @@ export class Ctx implements RustAnalyzerExtensionApi { for (const [name, factory] of Object.entries(this.commandFactories)) { const fullName = `rust-analyzer.${name}`; let callback; + if (isClientRunning(this)) { - // we asserted that `client` is defined - callback = factory.enabled(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); + } } else if (factory.disabled) { callback = factory.disabled(this); } else { |