This commit is contained in:
Benjamin Pasero
2018-01-23 19:33:12 +01:00
parent c9b291978c
commit d260ccffec
@@ -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' : '';
}