diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index 7f698036e98..510ef7de2b9 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -19,6 +19,8 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { IUntitledEditorService } from "vs/workbench/services/untitled/common/untitledEditorService"; +import { Schemas } from "vs/base/common/network"; export interface IEditorLabel { name: string; @@ -169,11 +171,27 @@ export interface IFileLabelOptions extends IResourceLabelOptions { export class FileLabel extends ResourceLabel { + constructor( + container: HTMLElement, + options: IIconLabelCreationOptions, + @IExtensionService extensionService: IExtensionService, + @IWorkspaceContextService contextService: IWorkspaceContextService, + @IConfigurationService configurationService: IConfigurationService, + @IModeService modeService: IModeService, + @IModelService modelService: IModelService, + @IEnvironmentService environmentService: IEnvironmentService, + @IUntitledEditorService private untitledEditorService: IUntitledEditorService + ) { + super(container, options, extensionService, contextService, configurationService, modeService, modelService, environmentService); + } + public setFile(resource: uri, options: IFileLabelOptions = Object.create(null)): void { + const hidePath = options.hidePath || (resource.scheme === Schemas.untitled && !this.untitledEditorService.hasAssociatedFilePath(resource)); + this.setLabel({ resource, name: !options.hideLabel ? paths.basename(resource.fsPath) : void 0, - description: !options.hidePath ? getPathLabel(paths.dirname(resource.fsPath), this.contextService, this.environmentService) : void 0 + description: !hidePath ? getPathLabel(paths.dirname(resource.fsPath), this.contextService, this.environmentService) : void 0 }, options); } }