From 45e95c62f6595eff6761ffd152272045b44251ff Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 1 Feb 2018 15:27:42 +0100 Subject: [PATCH] fixes #42626 --- src/vs/workbench/parts/files/common/explorerModel.ts | 2 +- .../parts/files/electron-browser/views/explorerView.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/parts/files/common/explorerModel.ts b/src/vs/workbench/parts/files/common/explorerModel.ts index f1d1f94387c47..621a89dba0332 100644 --- a/src/vs/workbench/parts/files/common/explorerModel.ts +++ b/src/vs/workbench/parts/files/common/explorerModel.ts @@ -153,7 +153,7 @@ export class FileStat implements IFileStat { * exists locally. */ public static mergeLocalWithDisk(disk: FileStat, local: FileStat): void { - if (!disk || !local || disk.resource.toString() !== local.resource.toString()) { + if (disk.resource.toString() !== local.resource.toString()) { return; // Merging only supported for stats with the same resource } diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts index df2af42c456e4..9df8a56822762 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts @@ -798,7 +798,11 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView return errorFileStat(targetsToResolve[index].resource, targetsToResolve[index].root); }); // Subsequent refresh: Merge stat into our local model and refresh tree - modelStats.forEach((modelStat, index) => FileStat.mergeLocalWithDisk(modelStat, this.model.roots[index])); + modelStats.forEach((modelStat, index) => { + if (index < this.model.roots.length) { + FileStat.mergeLocalWithDisk(modelStat, this.model.roots[index]); + } + }); const statsToExpand: FileStat[] = this.explorerViewer.getExpandedElements().concat(targetsToExpand.map(expand => this.model.findClosest(expand))); if (input === this.explorerViewer.getInput()) { @@ -817,7 +821,9 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView .then(result => FileStat.create(result, target.root, target.options.resolveTo), err => errorFileStat(target.resource, target.root)) .then(modelStat => { // Subsequent refresh: Merge stat into our local model and refresh tree - FileStat.mergeLocalWithDisk(modelStat, this.model.roots[index]); + if (index < this.model.roots.length) { + FileStat.mergeLocalWithDisk(modelStat, this.model.roots[index]); + } let toExpand: FileStat[] = this.explorerViewer.getExpandedElements().concat(targetsToExpand.map(target => this.model.findClosest(target))); if (input === this.explorerViewer.getInput()) {