This repository was archived by the owner on Nov 18, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 94
94
"title" : " Restart the RLS" ,
95
95
"description" : " Sometimes, it's just best to try turning it off and on again" ,
96
96
"category" : " Rust"
97
+ },
98
+ {
99
+ "command" : " rls.start" ,
100
+ "title" : " Start the RLS" ,
101
+ "description" : " Start the RLS (when rust-client.autoStartRls is false or when manually stopped)" ,
102
+ "category" : " Rust"
103
+ },
104
+ {
105
+ "command" : " rls.stop" ,
106
+ "title" : " Stop the RLS" ,
107
+ "description" : " Stop the RLS for a workspace until manually started again" ,
108
+ "category" : " Rust"
97
109
}
98
110
],
99
111
"taskDefinitions" : [
187
199
"default" : false ,
188
200
"description" : " Update the RLS whenever the extension starts up."
189
201
},
202
+ "rust-client.autoStartRls" : {
203
+ "type" : " boolean" ,
204
+ "default" : true ,
205
+ "description" : " Start RLS automatically when opening a file or project." ,
206
+ "scope" : " resource"
207
+ },
190
208
"rust-client.disableRustup" : {
191
209
"type" : " boolean" ,
192
210
"default" : false ,
Original file line number Diff line number Diff line change @@ -118,6 +118,13 @@ export class RLSConfiguration {
118
118
return this . configuration . get < string > ( 'rust-client.rlsPath' ) ;
119
119
}
120
120
121
+ /**
122
+ * Whether RLS should be automaticallystarted when opening a relevant Rust project.
123
+ */
124
+ public get autoStartRls ( ) : boolean {
125
+ return this . configuration . get < boolean > ( 'rust-client.autoStartRls' , true ) ;
126
+ }
127
+
121
128
// Added ignoreChannel for readChannel function. Otherwise we end in an infinite loop.
122
129
public rustupConfig ( ignoreChannel : boolean = false ) : RustupConfig {
123
130
return {
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ function clientWorkspaceForUri(
160
160
if ( ! existing && options && options . startIfMissing ) {
161
161
const workspace = new ClientWorkspace ( folder ) ;
162
162
workspaces . set ( folder . uri . toString ( ) , workspace ) ;
163
- workspace . start ( ) ;
163
+ workspace . auto_start ( ) ;
164
164
}
165
165
166
166
return workspaces . get ( folder . uri . toString ( ) ) ;
@@ -188,6 +188,12 @@ class ClientWorkspace {
188
188
this . _progress = new Observable < { message : string } | null > ( null ) ;
189
189
}
190
190
191
+ public auto_start ( ) {
192
+ if ( this . config . autoStartRls ) {
193
+ this . start ( ) ;
194
+ }
195
+ }
196
+
191
197
public async start ( ) {
192
198
this . _progress . value = { message : 'Starting' } ;
193
199
@@ -265,6 +271,7 @@ class ClientWorkspace {
265
271
public async stop ( ) {
266
272
if ( this . lc ) {
267
273
await this . lc . stop ( ) ;
274
+ this . lc = null ;
268
275
}
269
276
270
277
this . disposables . forEach ( d => d . dispose ( ) ) ;
@@ -466,6 +473,14 @@ function registerCommands(): Disposable[] {
466
473
'rls.run' ,
467
474
( cmd : Execution ) => activeWorkspace && activeWorkspace . runRlsCommand ( cmd ) ,
468
475
) ,
476
+ commands . registerCommand (
477
+ 'rls.start' ,
478
+ ( ) => activeWorkspace && activeWorkspace . start ( ) ,
479
+ ) ,
480
+ commands . registerCommand (
481
+ 'rls.stop' ,
482
+ ( ) => activeWorkspace && activeWorkspace . stop ( ) ,
483
+ ) ,
469
484
] ;
470
485
}
471
486
You can’t perform that action at this time.
0 commit comments