Skip to content

Commit 7731fd4

Browse files
committed
The symbol link icon could be refreshed when file is changed
1 parent 6627db2 commit 7731fd4

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/vs/workbench/browser/labels.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export interface IResourceLabelOptions extends IIconLabelValueOptions {
5757
* Will take the provided label as is and e.g. not override it for untitled files.
5858
*/
5959
readonly forceLabel?: boolean;
60+
61+
/**
62+
* Whether this resource is a symbolic link.
63+
*/
64+
readonly isSymbolicLink?: boolean;
6065
}
6166

6267
export interface IFileLabelOptions extends IResourceLabelOptions {
@@ -456,6 +461,7 @@ class ResourceLabelWidget extends IconLabel {
456461
}
457462
}
458463

464+
const hasIsSymbolicLinkChanged = this.hasIsSymbolicLinkChanged(options);
459465
const hasResourceChanged = this.hasResourceChanged(label);
460466
const hasPathLabelChanged = hasResourceChanged || this.hasPathLabelChanged(label);
461467
const hasFileKindChanged = this.hasFileKindChanged(options);
@@ -472,11 +478,18 @@ class ResourceLabelWidget extends IconLabel {
472478
}
473479

474480
this.render({
475-
updateIcon: hasResourceChanged || hasFileKindChanged,
476-
updateDecoration: hasResourceChanged || hasFileKindChanged
481+
updateIcon: hasResourceChanged || hasFileKindChanged || hasIsSymbolicLinkChanged,
482+
updateDecoration: hasResourceChanged || hasFileKindChanged || hasIsSymbolicLinkChanged
477483
});
478484
}
479485

486+
private hasIsSymbolicLinkChanged(newOptions?: IResourceLabelOptions): boolean {
487+
const isNewSymbolicLink = newOptions?.isSymbolicLink;
488+
const isOldSymbolicLink = this.options?.isSymbolicLink;
489+
490+
return isNewSymbolicLink !== isOldSymbolicLink;
491+
}
492+
480493
private hasFileKindChanged(newOptions?: IResourceLabelOptions): boolean {
481494
const newFileKind = newOptions?.fileKind;
482495
const oldFileKind = this.options?.fileKind;

src/vs/workbench/contrib/files/browser/views/explorerDecorationsProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
1313
import { explorerRootErrorEmitter } from 'vs/workbench/contrib/files/browser/views/explorerViewer';
1414
import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
1515
import { IExplorerService } from 'vs/workbench/contrib/files/browser/files';
16+
import { IFileService } from 'vs/platform/files/common/files';
1617

1718
export function provideDecorations(fileStat: ExplorerItem): IDecorationData | undefined {
1819
if (fileStat.isRoot && fileStat.isError) {
@@ -50,7 +51,8 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
5051

5152
constructor(
5253
@IExplorerService private explorerService: IExplorerService,
53-
@IWorkspaceContextService contextService: IWorkspaceContextService
54+
@IWorkspaceContextService contextService: IWorkspaceContextService,
55+
@IFileService fileService: IFileService,
5456
) {
5557
this.toDispose.add(this._onDidChange);
5658
this.toDispose.add(contextService.onDidChangeWorkspaceFolders(e => {
@@ -59,6 +61,9 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
5961
this.toDispose.add(explorerRootErrorEmitter.event((resource => {
6062
this._onDidChange.fire([resource]);
6163
})));
64+
this.toDispose.add(fileService.onDidFilesChange(e => {
65+
this._onDidChange.fire([...e.rawAdded, ...e.rawUpdated]);
66+
}));
6267
}
6368

6469
get onDidChange(): Event<URI[]> {

src/vs/workbench/contrib/files/browser/views/explorerView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
719719

720720
await promise;
721721
if (!this.decorationsProvider) {
722-
this.decorationsProvider = new ExplorerDecorationsProvider(this.explorerService, this.contextService);
722+
this.decorationsProvider = new ExplorerDecorationsProvider(this.explorerService, this.contextService, this.fileService);
723723
this._register(this.decorationService.registerDecorationsProvider(this.decorationsProvider));
724724
}
725725
}

src/vs/workbench/contrib/files/browser/views/explorerViewer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
418418
fileKind: stat.isRoot ? FileKind.ROOT_FOLDER : stat.isDirectory ? FileKind.FOLDER : FileKind.FILE,
419419
extraClasses: realignNestedChildren ? [...extraClasses, 'align-nest-icon-with-parent-icon'] : extraClasses,
420420
fileDecorations: this.config.explorer.decorations,
421+
isSymbolicLink: stat.isSymbolicLink,
421422
matches: createMatches(filterData),
422423
separator: this.labelService.getSeparator(stat.resource.scheme, stat.resource.authority),
423424
domId

0 commit comments

Comments
 (0)