diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2024-03-06 19:10:50 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2024-03-06 19:20:58 +0100 |
| commit | 1c6d1b4f2a812e2c3874a2ca93016ece25c3bf76 (patch) | |
| tree | 9a3ac9ba64208dd0a1f362591415b624d1489856 /editors/code/src | |
| parent | 52d8ae791d0b1218da57b1b2de4d114d1dff2981 (diff) | |
fix: Add config and capability for test explorer
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/client.ts | 8 | ||||
| -rw-r--r-- | editors/code/src/config.ts | 4 | ||||
| -rw-r--r-- | editors/code/src/ctx.ts | 20 |
3 files changed, 23 insertions, 9 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index c27a446b380..1cbf247297f 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -372,13 +372,18 @@ export async function createClient( ); // To turn on all proposed features use: client.registerProposedFeatures(); - client.registerFeature(new ExperimentalFeatures()); + client.registerFeature(new ExperimentalFeatures(config)); client.registerFeature(new OverrideFeatures()); return client; } class ExperimentalFeatures implements lc.StaticFeature { + private readonly testExplorer: boolean; + + constructor(config: Config) { + this.testExplorer = config.testExplorer || false; + } getState(): lc.FeatureState { return { kind: "static" }; } @@ -391,6 +396,7 @@ class ExperimentalFeatures implements lc.StaticFeature { colorDiagnosticOutput: true, openServerLogs: true, localDocs: true, + testExplorer: this.testExplorer, commands: { commands: [ "rust-analyzer.runSingle", diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 51a0aece820..92a816bfbcb 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -266,6 +266,10 @@ export class Config { return this.get<string | undefined>("cargoRunner"); } + get testExplorer() { + return this.get<boolean | undefined>("testExplorer"); + } + get runnablesExtraEnv() { const item = this.get<any>("runnables.extraEnv") ?? this.get<any>("runnableEnv"); if (!item) return item; diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 9be846f9692..f76dec2629a 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -75,7 +75,7 @@ export class Ctx implements RustAnalyzerExtensionApi { private _client: lc.LanguageClient | undefined; private _serverPath: string | undefined; private traceOutputChannel: vscode.OutputChannel | undefined; - private testController: vscode.TestController; + private testController: vscode.TestController | undefined; private outputChannel: vscode.OutputChannel | undefined; private clientSubscriptions: Disposable[]; private state: PersistentState; @@ -104,18 +104,20 @@ export class Ctx implements RustAnalyzerExtensionApi { workspace: Workspace, ) { extCtx.subscriptions.push(this); + this.config = new Config(extCtx); this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); - this.testController = vscode.tests.createTestController( - "rustAnalyzerTestController", - "Rust Analyzer test controller", - ); + if (this.config.testExplorer) { + this.testController = vscode.tests.createTestController( + "rustAnalyzerTestController", + "Rust Analyzer test controller", + ); + } this.workspace = workspace; this.clientSubscriptions = []; this.commandDisposables = []; this.commandFactories = commandFactories; this.unlinkedFiles = []; this.state = new PersistentState(extCtx.globalState); - this.config = new Config(extCtx); this.updateCommands("disable"); this.setServerStatus({ @@ -126,7 +128,7 @@ export class Ctx implements RustAnalyzerExtensionApi { dispose() { this.config.dispose(); this.statusBar.dispose(); - this.testController.dispose(); + this.testController?.dispose(); void this.disposeClient(); this.commandDisposables.forEach((disposable) => disposable.dispose()); } @@ -271,7 +273,9 @@ export class Ctx implements RustAnalyzerExtensionApi { await client.start(); this.updateCommands(); - prepareTestExplorer(this, this.testController, client); + if (this.testController) { + prepareTestExplorer(this, this.testController, client); + } if (this.config.showDependenciesExplorer) { this.prepareTreeDependenciesView(client); } |
