Merge pull request #126843 from gjsjohnmurray/fix-126842

fix #126842 clear Explorer root folder error indicator when refresh succeeds
This commit is contained in:
Isidor Nikolic 2021-08-02 16:41:43 +02:00 committed by GitHub
commit 97faef955a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 14 deletions

View file

@ -91,25 +91,34 @@ export class ExplorerDataSource implements IAsyncDataSource<ExplorerItem | Explo
return Promise.resolve(element);
}
const wasError = element.isError;
const sortOrder = this.explorerService.sortOrderConfiguration.sortOrder;
const promise = element.fetchChildren(sortOrder).then(undefined, e => {
if (element instanceof ExplorerItem && element.isRoot) {
if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
// Single folder create a dummy explorer item to show error
const placeholder = new ExplorerItem(element.resource, this.fileService, undefined, false);
placeholder.isError = true;
return [placeholder];
} else {
const promise = element.fetchChildren(sortOrder).then(
children => {
// Clear previous error decoration on root folder
if (element instanceof ExplorerItem && element.isRoot && !element.isError && wasError && this.contextService.getWorkbenchState() !== WorkbenchState.FOLDER) {
explorerRootErrorEmitter.fire(element.resource);
}
} else {
// Do not show error for roots since we already use an explorer decoration to notify user
this.notificationService.error(e);
return children;
}
, e => {
return []; // we could not resolve any children because of an error
});
if (element instanceof ExplorerItem && element.isRoot) {
if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
// Single folder create a dummy explorer item to show error
const placeholder = new ExplorerItem(element.resource, this.fileService, undefined, false);
placeholder.isError = true;
return [placeholder];
} else {
explorerRootErrorEmitter.fire(element.resource);
}
} else {
// Do not show error for roots since we already use an explorer decoration to notify user
this.notificationService.error(e);
}
return []; // we could not resolve any children because of an error
});
this.progressService.withProgress({
location: ProgressLocation.Explorer,

View file

@ -286,6 +286,7 @@ export class ExplorerItem {
// Resolve metadata only when the mtime is needed since this can be expensive
// Mtime is only used when the sort order is 'modified'
const resolveMetadata = sortOrder === SortOrder.Modified;
this.isError = false;
try {
const stat = await this.fileService.resolve(this.resource, { resolveSingleChildDescendants: true, resolveMetadata });
const resolved = ExplorerItem.create(this.fileService, stat, this);