From d260ccffecefd809ca81d856e857a0441522417e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 23 Jan 2018 19:33:07 +0100 Subject: [PATCH] workaround #41987 --- .../browser/parts/quickopen/quickOpenController.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 935b7d8bed58..1da92a9404f4 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -55,6 +55,7 @@ import { FileKind, IFileService } from 'vs/platform/files/common/files'; import { scoreItem, ScorerCache, compareItemsByScore, prepareQuery } from 'vs/base/parts/quickopen/common/quickOpenScorer'; import { getBaseLabel } from 'vs/base/common/labels'; import { WorkbenchTree } from 'vs/platform/list/browser/listService'; +import { dirname } from 'vs/base/common/paths'; const HELP_PREFIX = '?'; @@ -1259,7 +1260,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { const resourceInput = input as IResourceInput; this.resource = resourceInput.resource; this.label = getBaseLabel(resourceInput.resource); - this.description = labels.getPathLabel(resources.dirname(this.resource), contextService, environmentService); + this.description = labels.getPathLabel(this.safeDirname(this.resource), contextService, environmentService); this.dirty = this.resource && this.textFileService.isDirty(this.resource); if (this.dirty && this.textFileService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) { @@ -1268,6 +1269,16 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { } } + private safeDirname(resource: URI): string | URI { + try { + return resources.dirname(resource); // workaround for https://github.com/Microsoft/vscode/issues/41987 + } catch (error) { + console.warn(`Unable to resolve to parent resource: ${resource.toString()}`, resource, error); + + return dirname(resource.fsPath); + } + } + public getIcon(): string { return this.dirty ? 'dirty' : ''; }