@@ -75,7 +75,7 @@ export class Ctx implements RustAnalyzerExtensionApi {
7575 private _client : lc . LanguageClient | undefined ;
7676 private _serverPath : string | undefined ;
7777 private traceOutputChannel : vscode . OutputChannel | undefined ;
78- private testController : vscode . TestController ;
78+ private testController : vscode . TestController | undefined ;
7979 private outputChannel : vscode . OutputChannel | undefined ;
8080 private clientSubscriptions : Disposable [ ] ;
8181 private state : PersistentState ;
@@ -104,18 +104,20 @@ export class Ctx implements RustAnalyzerExtensionApi {
104104 workspace : Workspace ,
105105 ) {
106106 extCtx . subscriptions . push ( this ) ;
107+ this . config = new Config ( extCtx ) ;
107108 this . statusBar = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left ) ;
108- this . testController = vscode . tests . createTestController (
109- "rustAnalyzerTestController" ,
110- "Rust Analyzer test controller" ,
111- ) ;
109+ if ( this . config . testExplorer ) {
110+ this . testController = vscode . tests . createTestController (
111+ "rustAnalyzerTestController" ,
112+ "Rust Analyzer test controller" ,
113+ ) ;
114+ }
112115 this . workspace = workspace ;
113116 this . clientSubscriptions = [ ] ;
114117 this . commandDisposables = [ ] ;
115118 this . commandFactories = commandFactories ;
116119 this . unlinkedFiles = [ ] ;
117120 this . state = new PersistentState ( extCtx . globalState ) ;
118- this . config = new Config ( extCtx ) ;
119121
120122 this . updateCommands ( "disable" ) ;
121123 this . setServerStatus ( {
@@ -126,7 +128,7 @@ export class Ctx implements RustAnalyzerExtensionApi {
126128 dispose ( ) {
127129 this . config . dispose ( ) ;
128130 this . statusBar . dispose ( ) ;
129- this . testController . dispose ( ) ;
131+ this . testController ? .dispose ( ) ;
130132 void this . disposeClient ( ) ;
131133 this . commandDisposables . forEach ( ( disposable ) => disposable . dispose ( ) ) ;
132134 }
@@ -271,7 +273,9 @@ export class Ctx implements RustAnalyzerExtensionApi {
271273 await client . start ( ) ;
272274 this . updateCommands ( ) ;
273275
274- prepareTestExplorer ( this , this . testController , client ) ;
276+ if ( this . testController ) {
277+ prepareTestExplorer ( this , this . testController , client ) ;
278+ }
275279 if ( this . config . showDependenciesExplorer ) {
276280 this . prepareTreeDependenciesView ( client ) ;
277281 }
0 commit comments