Skip to content

Commit

Permalink
[theming] fix #6788: treat URI without ext as a file if there are ico…
Browse files Browse the repository at this point in the history
…ns matching to name or language

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Dec 26, 2019
1 parent ea270ba commit 5602c75
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions packages/plugin-ext/src/main/browser/plugin-icon-theme-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ export class PluginIconTheme extends PluginIconThemeDefinition implements IconTh
return [this.rootFolderExpandedIcon, this.expandedFolderNameIcon(name)];
}
return [this.rootFolderIcon, this.folderNameIcon(name)];
} if (DirNode.is(element)) {
}
if (DirNode.is(element)) {
if (element.expanded) {
const name = this.labelProvider.getName(element);
return [this.folderExpandedIcon, this.expandedFolderNameIcon(name)];
Expand All @@ -493,10 +494,21 @@ export class PluginIconTheme extends PluginIconThemeDefinition implements IconTh
}
return this.getFileClassNames(element, element.uri);
}
if (!element.path.ext) {
return this.getFolderClassNames(element);
return this.getClassNamesForUri(element);
}

protected getClassNamesForUri(uri: URI): string[] {
const name = this.labelProvider.getName(uri);
let classNames = this.fileIcons(name, uri.toString());
if (!uri.path.ext) {
classNames = classNames.filter(className => this.icons.has(className));
// treat URI as folder only if there are no icons for name, extensions and language of a given URI
if (!classNames.length) {
return [this.folderIcon, this.folderNameIcon(name)];
}
}
return this.getFileClassNames(element, element.toString());
classNames.unshift(this.fileIcon);
return classNames;
}

protected getFolderClassNames(element: object): string[] {
Expand All @@ -506,8 +518,13 @@ export class PluginIconTheme extends PluginIconThemeDefinition implements IconTh

protected getFileClassNames(element: URI | FileStat | FileStatNode, uri: string): string[] {
const name = this.labelProvider.getName(element);
const classNames = this.fileNameIcon(name);
const classNames = this.fileIcons(name, uri);
classNames.unshift(this.fileIcon);
return classNames;
}

protected fileIcons(fileName: string, uri: string): string[] {
const classNames = this.fileNameIcon(fileName);
const language = monaco.services.StaticServices.modeService.get().createByFilepathOrFirstLine(monaco.Uri.parse(uri));
classNames.push(this.languageIcon(language.languageIdentifier.language));
return classNames;
Expand Down

0 comments on commit 5602c75

Please sign in to comment.