提交 6faa350e 编写于 作者: I isidor

basenameOrAuthority

上级 1b6fd47b
......@@ -7,10 +7,6 @@
import * as paths from 'vs/base/common/paths';
import uri from 'vs/base/common/uri';
export function basename(resource: uri): string {
if (resource.scheme === 'file' || resource.scheme === 'untitled') {
return paths.basename(resource.fsPath);
}
return paths.basename(resource.authority + resource.path);
export function basenameOrAuthority(resource: uri): string {
return paths.basename(resource.fsPath) || resource.authority;
}
......@@ -217,11 +217,11 @@ export class FileLabel extends ResourceLabel {
getWorkspace(): { folders: uri[]; } { return { folders: [options.root] }; },
} : this.contextService;
const description = resource.scheme === 'file' ? getPathLabel(paths.dirname(resource.fsPath), rootProvider, this.environmentService) : resource.authority;
const description = resource.scheme === 'file' || resource.scheme === 'untitled' ? getPathLabel(paths.dirname(resource.fsPath), rootProvider, this.environmentService) : resource.authority;
this.setLabel({
resource,
name: (options && options.hideLabel) ? void 0 : resources.basename(resource),
name: (options && options.hideLabel) ? void 0 : resources.basenameOrAuthority(resource),
description: !hidePath ? description : void 0
}, options);
}
......@@ -234,28 +234,28 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
if (resource) {
const basename = cssEscape(resources.basename(resource).toLowerCase());
const name = cssEscape(resources.basenameOrAuthority(resource).toLowerCase());
// Folders
if (fileKind === FileKind.FOLDER) {
classes.push(`${basename}-name-folder-icon`);
classes.push(`${name}-name-folder-icon`);
}
// Files
else {
// Name
classes.push(`${basename}-name-file-icon`);
classes.push(`${name}-name-file-icon`);
// Extension(s)
const dotSegments = basename.split('.');
const dotSegments = name.split('.');
for (let i = 1; i < dotSegments.length; i++) {
classes.push(`${dotSegments.slice(i).join('.')}-ext-file-icon`); // add each combination of all found extensions if more than one
}
// Configured Language
let configuredLangId = getConfiguredLangId(modelService, resource);
configuredLangId = configuredLangId || modeService.getModeIdByFilenameOrFirstLine(basename);
configuredLangId = configuredLangId || modeService.getModeIdByFilenameOrFirstLine(name);
if (configuredLangId) {
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册