@@ -69,7 +69,7 @@ class ExtHostWorkspaceImpl extends Workspace {
6969 // data and update their properties. It could be that an extension stored them
7070 // for later use and we want to keep them "live" if they are still present.
7171 const oldWorkspace = previousConfirmedWorkspace ;
72- if ( oldWorkspace ) {
72+ if ( previousConfirmedWorkspace ) {
7373 folders . forEach ( ( folderData , index ) => {
7474 const folderUri = URI . revive ( folderData . uri ) ;
7575 const existingFolder = ExtHostWorkspaceImpl . _findFolder ( previousUnconfirmedWorkspace || previousConfirmedWorkspace , folderUri ) ;
@@ -128,15 +128,15 @@ class ExtHostWorkspaceImpl extends Workspace {
128128 return this . _workspaceFolders . slice ( 0 ) ;
129129 }
130130
131- getWorkspaceFolder ( uri : URI , resolveParent ?: boolean ) : vscode . WorkspaceFolder {
131+ getWorkspaceFolder ( uri : URI , resolveParent ?: boolean ) : vscode . WorkspaceFolder | undefined {
132132 if ( resolveParent && this . _structure . get ( uri . toString ( ) ) ) {
133133 // `uri` is a workspace folder so we check for its parent
134- uri = dirname ( uri ) ;
134+ uri = dirname ( uri ) ! ;
135135 }
136136 return this . _structure . findSubstr ( uri . toString ( ) ) ;
137137 }
138138
139- resolveWorkspaceFolder ( uri : URI ) : vscode . WorkspaceFolder {
139+ resolveWorkspaceFolder ( uri : URI ) : vscode . WorkspaceFolder | undefined {
140140 return this . _structure . get ( uri . toString ( ) ) ;
141141 }
142142}
@@ -147,7 +147,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
147147 private readonly _logService : ILogService ;
148148 private readonly _requestIdProvider : Counter ;
149149 private readonly _barrier : Barrier ;
150- private _actual : ExtHostWorkspaceProvider ;
150+ private _actual : ExtHostWorkspaceProvider | null ;
151151
152152 constructor (
153153 mainContext : IMainContext ,
@@ -162,7 +162,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
162162 }
163163
164164 public getWorkspaceProvider ( ) : Promise < ExtHostWorkspaceProvider > {
165- return this . _barrier . wait ( ) . then ( _ => this . _actual ) ;
165+ return this . _barrier . wait ( ) . then ( _ => this . _actual ! ) ;
166166 }
167167
168168 $initializeWorkspace ( data : IWorkspaceData ) : void {
@@ -187,7 +187,7 @@ export class ExtHostWorkspaceProvider {
187187
188188 private readonly _onDidChangeWorkspace = new Emitter < vscode . WorkspaceFoldersChangeEvent > ( ) ;
189189
190- private _confirmedWorkspace : ExtHostWorkspaceImpl ;
190+ private _confirmedWorkspace ? : ExtHostWorkspaceImpl ;
191191 private _unconfirmedWorkspace ?: ExtHostWorkspaceImpl ;
192192
193193 private readonly _proxy : MainThreadWorkspaceShape ;
@@ -205,20 +205,20 @@ export class ExtHostWorkspaceProvider {
205205 ) {
206206 this . _proxy = mainContext . getProxy ( MainContext . MainThreadWorkspace ) ;
207207 this . _messageService = mainContext . getProxy ( MainContext . MainThreadMessageService ) ;
208- this . _confirmedWorkspace = ExtHostWorkspaceImpl . toExtHostWorkspace ( data ) . workspace ;
208+ this . _confirmedWorkspace = ExtHostWorkspaceImpl . toExtHostWorkspace ( data ) . workspace || undefined ;
209209 }
210210
211211 // --- workspace ---
212212
213- get workspace ( ) : Workspace {
213+ get workspace ( ) : Workspace | undefined {
214214 return this . _actualWorkspace ;
215215 }
216216
217217 get name ( ) : string | undefined {
218218 return this . _actualWorkspace ? this . _actualWorkspace . name : undefined ;
219219 }
220220
221- private get _actualWorkspace ( ) : ExtHostWorkspaceImpl {
221+ private get _actualWorkspace ( ) : ExtHostWorkspaceImpl | undefined {
222222 return this . _unconfirmedWorkspace || this . _confirmedWorkspace ;
223223 }
224224
@@ -258,7 +258,7 @@ export class ExtHostWorkspaceProvider {
258258
259259 // Simulate the updateWorkspaceFolders method on our data to do more validation
260260 const newWorkspaceFolders = currentWorkspaceFolders . slice ( 0 ) ;
261- newWorkspaceFolders . splice ( index , deleteCount , ...validatedDistinctWorkspaceFoldersToAdd . map ( f => ( { uri : f . uri , name : f . name || basenameOrAuthority ( f . uri ) , index : undefined } ) ) ) ;
261+ newWorkspaceFolders . splice ( index , deleteCount , ...validatedDistinctWorkspaceFoldersToAdd . map ( f => ( { uri : f . uri , name : f . name || basenameOrAuthority ( f . uri ) , index : undefined ! /* fixed later */ } ) ) ) ;
262262
263263 for ( let i = 0 ; i < newWorkspaceFolders . length ; i ++ ) {
264264 const folder = newWorkspaceFolders [ i ] ;
@@ -293,7 +293,7 @@ export class ExtHostWorkspaceProvider {
293293 return true ;
294294 }
295295
296- getWorkspaceFolder ( uri : vscode . Uri , resolveParent ?: boolean ) : vscode . WorkspaceFolder {
296+ getWorkspaceFolder ( uri : vscode . Uri , resolveParent ?: boolean ) : vscode . WorkspaceFolder | undefined {
297297 if ( ! this . _actualWorkspace ) {
298298 return undefined ;
299299 }
@@ -346,7 +346,7 @@ export class ExtHostWorkspaceProvider {
346346 return path ;
347347 }
348348
349- if ( typeof includeWorkspace === 'undefined' ) {
349+ if ( typeof includeWorkspace === 'undefined' && this . _actualWorkspace ) {
350350 includeWorkspace = this . _actualWorkspace . folders . length > 1 ;
351351 }
352352
@@ -367,7 +367,7 @@ export class ExtHostWorkspaceProvider {
367367 name : this . _actualWorkspace . name ,
368368 configuration : this . _actualWorkspace . configuration ,
369369 folders
370- } as IWorkspaceData , this . _actualWorkspace ) . workspace ;
370+ } as IWorkspaceData , this . _actualWorkspace ) . workspace || undefined ;
371371 }
372372 }
373373
@@ -377,7 +377,7 @@ export class ExtHostWorkspaceProvider {
377377
378378 // Update our workspace object. We have a confirmed workspace, so we drop our
379379 // unconfirmed workspace.
380- this . _confirmedWorkspace = workspace ;
380+ this . _confirmedWorkspace = workspace || undefined ;
381381 this . _unconfirmedWorkspace = undefined ;
382382
383383 // Events
@@ -405,7 +405,7 @@ export class ExtHostWorkspaceProvider {
405405 }
406406 }
407407
408- let excludePatternOrDisregardExcludes : string | false | undefined ;
408+ let excludePatternOrDisregardExcludes : string | false = false ;
409409 if ( exclude === null ) {
410410 excludePatternOrDisregardExcludes = false ;
411411 } else if ( exclude ) {
0 commit comments