mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
fix #76573
This commit is contained in:
@@ -317,40 +317,31 @@ class ResourceLabelWidget extends IconLabel {
|
||||
}
|
||||
|
||||
notifyFormattersChange(): void {
|
||||
if (this.label && this.label.resource) {
|
||||
this.setFile(this.label.resource, this.options);
|
||||
}
|
||||
this.render(false);
|
||||
}
|
||||
|
||||
setResource(label: IResourceLabelProps, options?: IResourceLabelOptions): void {
|
||||
const hasResourceChanged = this.hasResourceChanged(label, options);
|
||||
|
||||
this.label = label;
|
||||
this.options = options;
|
||||
|
||||
if (hasResourceChanged) {
|
||||
if (this.hasPathLabelChanged(label, options)) {
|
||||
this.computedPathLabel = undefined; // reset path label due to resource change
|
||||
}
|
||||
|
||||
this.render(hasResourceChanged);
|
||||
this.render(this.clearIconCache(label, options));
|
||||
}
|
||||
|
||||
private hasResourceChanged(label: IResourceLabelProps, options?: IResourceLabelOptions): boolean {
|
||||
const newResource = label ? label.resource : undefined;
|
||||
private clearIconCache(newLabel: IResourceLabelProps, newOptions?: IResourceLabelOptions): boolean {
|
||||
const newResource = newLabel ? newLabel.resource : undefined;
|
||||
const oldResource = this.label ? this.label.resource : undefined;
|
||||
|
||||
const newFileKind = options ? options.fileKind : undefined;
|
||||
const newFileKind = newOptions ? newOptions.fileKind : undefined;
|
||||
const oldFileKind = this.options ? this.options.fileKind : undefined;
|
||||
|
||||
if (newFileKind !== oldFileKind) {
|
||||
return true; // same resource but different kind (file, folder)
|
||||
}
|
||||
|
||||
if (newResource && this.computedPathLabel !== this.labelService.getUriLabel(newResource)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (newResource && oldResource) {
|
||||
return newResource.toString() !== oldResource.toString();
|
||||
}
|
||||
@@ -362,6 +353,12 @@ class ResourceLabelWidget extends IconLabel {
|
||||
return true;
|
||||
}
|
||||
|
||||
private hasPathLabelChanged(newLabel: IResourceLabelProps, newOptions?: IResourceLabelOptions): boolean {
|
||||
const newResource = newLabel ? newLabel.resource : undefined;
|
||||
|
||||
return !!newResource && this.computedPathLabel !== this.labelService.getUriLabel(newResource);
|
||||
}
|
||||
|
||||
setEditor(editor: IEditorInput, options?: IResourceLabelOptions): void {
|
||||
this.setResource({
|
||||
resource: toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }),
|
||||
|
||||
Reference in New Issue
Block a user