@@ -4,7 +4,14 @@ import * as ra from "./lsp_ext";
44
55import { Config , substituteVSCodeVariables } from "./config" ;
66import { createClient } from "./client" ;
7- import { executeDiscoverProject , isRustDocument , isRustEditor , LazyOutputChannel , log , RustEditor } from "./util" ;
7+ import {
8+ executeDiscoverProject ,
9+ isRustDocument ,
10+ isRustEditor ,
11+ LazyOutputChannel ,
12+ log ,
13+ RustEditor ,
14+ } from "./util" ;
815import { ServerStatusParams } from "./lsp_ext" ;
916import { PersistentState } from "./persistent_state" ;
1017import { bootstrap } from "./bootstrap" ;
@@ -17,12 +24,12 @@ import { ExecOptions } from "child_process";
1724export type Workspace =
1825 | { kind : "Empty" }
1926 | {
20- kind : "Workspace Folder" ;
21- }
27+ kind : "Workspace Folder" ;
28+ }
2229 | {
23- kind : "Detached Files" ;
24- files : vscode . TextDocument [ ] ;
25- } ;
30+ kind : "Detached Files" ;
31+ files : vscode . TextDocument [ ] ;
32+ } ;
2633
2734export function fetchWorkspace ( ) : Workspace {
2835 const folders = ( vscode . workspace . workspaceFolders || [ ] ) . filter (
@@ -36,13 +43,17 @@ export function fetchWorkspace(): Workspace {
3643 ? rustDocuments . length === 0
3744 ? { kind : "Empty" }
3845 : {
39- kind : "Detached Files" ,
40- files : rustDocuments ,
41- }
46+ kind : "Detached Files" ,
47+ files : rustDocuments ,
48+ }
4249 : { kind : "Workspace Folder" } ;
4350}
4451
45- export async function discoverWorkspace ( files : readonly vscode . TextDocument [ ] , command : string [ ] , options : ExecOptions ) : Promise < JsonProject > {
52+ export async function discoverWorkspace (
53+ files : readonly vscode . TextDocument [ ] ,
54+ command : string [ ] ,
55+ options : ExecOptions
56+ ) : Promise < JsonProject > {
4657 const paths = files . map ( ( f ) => f . uri . fsPath ) . join ( " " ) ;
4758 const joinedCommand = command . join ( " " ) ;
4859 const data = await executeDiscoverProject ( `${ joinedCommand } -- ${ paths } ` , options ) ;
@@ -80,7 +91,7 @@ export class Ctx {
8091 constructor (
8192 readonly extCtx : vscode . ExtensionContext ,
8293 commandFactories : Record < string , CommandFactory > ,
83- workspace : Workspace ,
94+ workspace : Workspace
8495 ) {
8596 extCtx . subscriptions . push ( this ) ;
8697 this . statusBar = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left ) ;
@@ -180,16 +191,22 @@ export class Ctx {
180191
181192 const discoverProjectCommand = this . config . discoverProjectCommand ;
182193 if ( discoverProjectCommand ) {
183- let workspaces : JsonProject [ ] = await Promise . all ( vscode . workspace . workspaceFolders ! . map ( async ( folder ) : Promise < JsonProject > => {
184- return discoverWorkspace ( vscode . workspace . textDocuments , discoverProjectCommand , { cwd : folder . uri . fsPath } ) ;
185- } ) ) ;
194+ const workspaces : JsonProject [ ] = await Promise . all (
195+ vscode . workspace . workspaceFolders ! . map ( async ( folder ) : Promise < JsonProject > => {
196+ return discoverWorkspace (
197+ vscode . workspace . textDocuments ,
198+ discoverProjectCommand ,
199+ { cwd : folder . uri . fsPath }
200+ ) ;
201+ } )
202+ ) ;
186203
187204 this . discoveredWorkspaces = workspaces ;
188205 }
189206
190- let initializationOptions = substituteVSCodeVariables ( rawInitializationOptions ) ;
207+ const initializationOptions = substituteVSCodeVariables ( rawInitializationOptions ) ;
191208 // this appears to be load-bearing, for better or worse.
192- await initializationOptions . update ( ' linkedProjects' , this . discoveredWorkspaces )
209+ await initializationOptions . update ( " linkedProjects" , this . discoveredWorkspaces ) ;
193210
194211 this . _client = await createClient (
195212 this . traceOutputChannel ,
0 commit comments