@@ -114,6 +114,7 @@ export class ResourceLabels extends Disposable {
114
114
@IInstantiationService private readonly instantiationService : IInstantiationService ,
115
115
@IConfigurationService private readonly configurationService : IConfigurationService ,
116
116
@IModelService private readonly modelService : IModelService ,
117
+ @IWorkspaceContextService private readonly workspaceService : IWorkspaceContextService ,
117
118
@ILanguageService private readonly languageService : ILanguageService ,
118
119
@IDecorationsService private readonly decorationsService : IDecorationsService ,
119
120
@IThemeService private readonly themeService : IThemeService ,
@@ -153,6 +154,11 @@ export class ResourceLabels extends Disposable {
153
154
this . widgets . forEach ( widget => widget . notifyModelAdded ( model ) ) ;
154
155
} ) ) ;
155
156
157
+ // notify when workspace folders changes
158
+ this . _register ( this . workspaceService . onDidChangeWorkspaceFolders ( ( ) => {
159
+ this . widgets . forEach ( widget => widget . notifyWorkspaceFoldersChange ( ) ) ;
160
+ } ) ) ;
161
+
156
162
// notify when file decoration changes
157
163
this . _register ( this . decorationsService . onDidChangeDecorations ( e => {
158
164
let notifyDidChangeDecorations = false ;
@@ -250,13 +256,14 @@ export class ResourceLabel extends ResourceLabels {
250
256
@IInstantiationService instantiationService : IInstantiationService ,
251
257
@IConfigurationService configurationService : IConfigurationService ,
252
258
@IModelService modelService : IModelService ,
259
+ @IWorkspaceContextService workspaceService : IWorkspaceContextService ,
253
260
@ILanguageService languageService : ILanguageService ,
254
261
@IDecorationsService decorationsService : IDecorationsService ,
255
262
@IThemeService themeService : IThemeService ,
256
263
@ILabelService labelService : ILabelService ,
257
264
@ITextFileService textFileService : ITextFileService
258
265
) {
259
- super ( DEFAULT_LABELS_CONTAINER , instantiationService , configurationService , modelService , languageService , decorationsService , themeService , labelService , textFileService ) ;
266
+ super ( DEFAULT_LABELS_CONTAINER , instantiationService , configurationService , modelService , workspaceService , languageService , decorationsService , themeService , labelService , textFileService ) ;
260
267
261
268
this . label = this . _register ( this . create ( container , options ) ) ;
262
269
}
@@ -279,6 +286,7 @@ class ResourceLabelWidget extends IconLabel {
279
286
private computedIconClasses : string [ ] | undefined = undefined ;
280
287
private computedLanguageId : string | undefined = undefined ;
281
288
private computedPathLabel : string | undefined = undefined ;
289
+ private computedWorkspaceFolderLabel : string | undefined = undefined ;
282
290
283
291
private needsRedraw : Redraw | undefined = undefined ;
284
292
private isHidden : boolean = false ;
@@ -374,6 +382,15 @@ class ResourceLabelWidget extends IconLabel {
374
382
}
375
383
}
376
384
385
+ notifyWorkspaceFoldersChange ( ) : void {
386
+ if ( typeof this . computedWorkspaceFolderLabel === 'string' ) {
387
+ const resource = toResource ( this . label ) ;
388
+ if ( URI . isUri ( resource ) && this . label ?. name === this . computedWorkspaceFolderLabel ) {
389
+ this . setFile ( resource , this . options ) ;
390
+ }
391
+ }
392
+ }
393
+
377
394
setFile ( resource : URI , options ?: IFileLabelOptions ) : void {
378
395
const hideLabel = options ?. hideLabel ;
379
396
let name : string | undefined ;
@@ -382,6 +399,7 @@ class ResourceLabelWidget extends IconLabel {
382
399
const workspaceFolder = this . contextService . getWorkspaceFolder ( resource ) ;
383
400
if ( workspaceFolder ) {
384
401
name = workspaceFolder . name ;
402
+ this . computedWorkspaceFolderLabel = name ;
385
403
}
386
404
}
387
405
@@ -602,5 +620,6 @@ class ResourceLabelWidget extends IconLabel {
602
620
this . computedLanguageId = undefined ;
603
621
this . computedIconClasses = undefined ;
604
622
this . computedPathLabel = undefined ;
623
+ this . computedWorkspaceFolderLabel = undefined ;
605
624
}
606
625
}
0 commit comments