提交 b1cf5a08 编写于 作者: B Benjamin Pasero

support name property of workspace folder in FileLabel

上级 efdc3280
......@@ -210,17 +210,33 @@ export class FileLabel extends ResourceLabel {
}
public setFile(resource: uri, options?: IFileLabelOptions): void {
let name: string;
if (options && options.hideLabel) {
name = void 0;
} else if (options && options.fileKind === FileKind.ROOT_FOLDER) {
const workspaceFolder = this.contextService.getWorkspaceFolder(resource);
name = workspaceFolder.name;
} else {
name = paths.basename(resource.fsPath);
}
let description: string;
const hidePath = (options && options.hidePath) || (resource.scheme === Schemas.untitled && !this.untitledEditorService.hasAssociatedFilePath(resource));
const rootProvider: IWorkspaceFolderProvider = (options && options.root) ? {
getWorkspaceFolder(): { uri: uri } { return { uri: options.root }; },
getWorkspace(): { folders: { uri: uri }[]; } { return { folders: [{ uri: options.root }] }; },
} : this.contextService;
if (!hidePath) {
let rootProvider: IWorkspaceFolderProvider;
if (options && options.root) {
rootProvider = {
getWorkspaceFolder(): { uri } { return { uri: options.root }; },
getWorkspace(): { folders: { uri: uri }[]; } { return { folders: [{ uri: options.root }] }; },
};
} else {
rootProvider = this.contextService;
}
this.setLabel({
resource,
name: (options && options.hideLabel) ? void 0 : paths.basename(resource.fsPath),
description: !hidePath ? getPathLabel(paths.dirname(resource.fsPath), rootProvider, this.environmentService) : void 0
}, options);
description = getPathLabel(paths.dirname(resource.fsPath), rootProvider, this.environmentService);
}
this.setLabel({ resource, name, description }, options);
}
}
......
......@@ -217,6 +217,10 @@ contributionRegistry.registerSchema('vscode://schemas/workspaceConfig', {
path: {
type: 'string',
description: nls.localize('workspaceConfig.folder.description', "A file path. e.g. `/root/folderA` or `./folderA` for a relative path that will be resolved against the location of the workspace file.")
},
name: {
type: 'string',
description: nls.localize('workspaceConfig.name.description', "An optional name for the folder. ")
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册