@@ -92,14 +92,13 @@ function didOpenTextDocument(
92
92
const folderPath = folder . uri . toString ( ) ;
93
93
94
94
if ( ! workspaces . has ( folderPath ) ) {
95
-
96
95
const workspace = new ClientWorkspace ( folder ) ;
97
96
activeWorkspace = workspace ;
98
97
workspaces . set ( folderPath , workspace ) ;
99
98
workspace . start ( context ) ;
100
99
} else {
101
100
const ws = workspaces . get ( folderPath ) ;
102
- activeWorkspace = typeof ws === " undefined" ? null : ws ;
101
+ activeWorkspace = typeof ws === ' undefined' ? null : ws ;
103
102
}
104
103
}
105
104
@@ -124,36 +123,39 @@ function sortedWorkspaceFolders(): string[] {
124
123
return _sortedWorkspaceFolders || [ ] ;
125
124
}
126
125
127
- function getCargoTomlWorkspace ( cur_workspace : WorkspaceFolder , file_path : string ) : WorkspaceFolder {
128
- if ( ! cur_workspace ) {
129
- return cur_workspace ;
130
- }
126
+ function getCargoTomlWorkspace (
127
+ curWorkspace : WorkspaceFolder ,
128
+ filePath : string ,
129
+ ) : WorkspaceFolder {
130
+ if ( ! curWorkspace ) {
131
+ return curWorkspace ;
132
+ }
131
133
132
- const workspace_root = path . parse ( cur_workspace . uri . fsPath ) . dir ;
133
- const root_manifest = path . join ( workspace_root , 'Cargo.toml' ) ;
134
- if ( fs . existsSync ( root_manifest ) ) {
135
- return cur_workspace ;
136
- }
134
+ const workspaceRoot = path . parse ( curWorkspace . uri . fsPath ) . dir ;
135
+ const rootManifest = path . join ( workspaceRoot , 'Cargo.toml' ) ;
136
+ if ( fs . existsSync ( rootManifest ) ) {
137
+ return curWorkspace ;
138
+ }
137
139
138
- let current = file_path ;
140
+ let current = filePath ;
139
141
140
- while ( true ) {
141
- const old = current ;
142
- current = path . dirname ( current ) ;
143
- if ( old == current ) {
144
- break ;
145
- }
146
- if ( workspace_root == path . parse ( current ) . dir ) {
147
- break ;
148
- }
142
+ while ( true ) {
143
+ const old = current ;
144
+ current = path . dirname ( current ) ;
145
+ if ( old = == current ) {
146
+ break ;
147
+ }
148
+ if ( workspaceRoot = == path . parse ( current ) . dir ) {
149
+ break ;
150
+ }
149
151
150
- const cargo_path = path . join ( current , 'Cargo.toml' ) ;
151
- if ( fs . existsSync ( cargo_path ) ) {
152
- return { ...cur_workspace , uri : Uri . parse ( current ) } ;
153
- }
152
+ const cargoPath = path . join ( current , 'Cargo.toml' ) ;
153
+ if ( fs . existsSync ( cargoPath ) ) {
154
+ return { ...curWorkspace , uri : Uri . parse ( current ) } ;
154
155
}
156
+ }
155
157
156
- return cur_workspace ;
158
+ return curWorkspace ;
157
159
}
158
160
159
161
function getOuterMostWorkspaceFolder ( folder : WorkspaceFolder ) : WorkspaceFolder {
@@ -230,16 +232,19 @@ class ClientWorkspace {
230
232
warnOnMissingCargoToml ( ) ;
231
233
}
232
234
233
-
234
235
startSpinner ( 'RLS' , 'Starting' ) ;
235
236
236
237
const serverOptions : ServerOptions = async ( ) => {
237
238
await this . autoUpdate ( ) ;
238
239
return this . makeRlsProcess ( ) ;
239
240
} ;
240
241
241
- const pattern = this . config . multiProjectEnabled ? `${ this . folder . uri . path } /**` : undefined ;
242
- const collectionName = this . config . multiProjectEnabled ? `rust ${ this . folder . uri . toString ( ) } ` : 'rust' ;
242
+ const pattern = this . config . multiProjectEnabled
243
+ ? `${ this . folder . uri . path } /**`
244
+ : undefined ;
245
+ const collectionName = this . config . multiProjectEnabled
246
+ ? `rust ${ this . folder . uri . toString ( ) } `
247
+ : 'rust' ;
243
248
const clientOptions : LanguageClientOptions = {
244
249
// Register the server for Rust files
245
250
@@ -283,7 +288,9 @@ class ClientWorkspace {
283
288
clientOptions ,
284
289
) ;
285
290
286
- const selector = this . config . multiProjectEnabled ? { language : 'rust' , scheme : 'file' , pattern } : { language : 'rust' } ;
291
+ const selector = this . config . multiProjectEnabled
292
+ ? { language : 'rust' , scheme : 'file' , pattern }
293
+ : { language : 'rust' } ;
287
294
288
295
this . setupProgressCounter ( ) ;
289
296
this . registerCommands ( context , this . config . multiProjectEnabled ) ;
@@ -308,7 +315,10 @@ class ClientWorkspace {
308
315
commandsUnregistered = true ;
309
316
}
310
317
311
- private registerCommands ( context : ExtensionContext , multiProjectEnabled : boolean ) {
318
+ private registerCommands (
319
+ context : ExtensionContext ,
320
+ multiProjectEnabled : boolean ,
321
+ ) {
312
322
if ( ! this . lc ) {
313
323
return ;
314
324
}
@@ -320,27 +330,27 @@ class ClientWorkspace {
320
330
const rustupUpdateDisposable = commands . registerCommand (
321
331
'rls.update' ,
322
332
( ) => {
323
- const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
333
+ const ws =
334
+ multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
324
335
return rustupUpdate ( ws . config . rustupConfig ( ) ) ;
325
336
} ,
326
337
) ;
327
338
this . disposables . push ( rustupUpdateDisposable ) ;
328
339
329
340
const restartServer = commands . registerCommand ( 'rls.restart' , async ( ) => {
330
- const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
341
+ const ws =
342
+ multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
331
343
await ws . stop ( ) ;
332
344
return ws . start ( context ) ;
333
-
334
345
} ) ;
335
346
this . disposables . push ( restartServer ) ;
336
347
337
348
this . disposables . push (
338
349
commands . registerCommand ( 'rls.run' , ( cmd : Execution ) => {
339
- const ws = multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
340
- runRlsCommand ( ws . folder , cmd )
341
- } ,
342
-
343
- ) ,
350
+ const ws =
351
+ multiProjectEnabled && activeWorkspace ? activeWorkspace : this ;
352
+ runRlsCommand ( ws . folder , cmd ) ;
353
+ } ) ,
344
354
) ;
345
355
}
346
356
0 commit comments