Skip to content

Commit

Permalink
feat: support iconThemes definitions for root folders (#195319)
Browse files Browse the repository at this point in the history
Co-authored-by: ermin.zem <ermin.zem@alibaba-inc.com>
  • Loading branch information
harbin1053020115 and alijs authored Oct 12, 2023
1 parent 7a03774 commit 2b9791e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/vs/editor/common/services/getIconClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ export function getIconClasses(modelService: IModelService, languageService: ILa
}
}

// Root Folders
if (fileKind === FileKind.ROOT_FOLDER) {
classes.push(`${name}-root-name-folder-icon`);
}

// Folders
if (fileKind === FileKind.FOLDER) {
else if (fileKind === FileKind.FOLDER) {
classes.push(`${name}-name-folder-icon`);
}

Expand Down
17 changes: 17 additions & 0 deletions src/vs/workbench/services/themes/browser/fileIconThemeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ interface IconsAssociation {
folderExpanded?: string;
rootFolder?: string;
rootFolderExpanded?: string;
rootFolderNames?: { [folderName: string]: string };
rootFolderNamesExpanded?: { [folderName: string]: string };
folderNames?: { [folderName: string]: string };
folderNamesExpanded?: { [folderName: string]: string };
fileExtensions?: { [extension: string]: string };
Expand Down Expand Up @@ -309,6 +311,21 @@ export class FileIconThemeLoader {
}
}

const rootFolderNames = associations.rootFolderNames;
if (rootFolderNames) {
for (const key in rootFolderNames) {
addSelector(`${qualifier} .${escapeCSS(key)}-root-name-folder-icon.rootfolder-icon::before`, rootFolderNames[key]);
result.hasFolderIcons = true;
}
}
const rootFolderNamesExpanded = associations.rootFolderNamesExpanded;
if (rootFolderNamesExpanded) {
for (const key in rootFolderNamesExpanded) {
addSelector(`${qualifier} ${expanded} .${escapeCSS(key)}-root-name-folder-icon.rootfolder-icon::before`, rootFolderNamesExpanded[key]);
result.hasFolderIcons = true;
}
}

const languageIds = associations.languageIds;
if (languageIds) {
if (!languageIds.jsonc && languageIds.json) {
Expand Down
16 changes: 16 additions & 0 deletions src/vs/workbench/services/themes/common/fileIconThemeSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ const schema: IJSONSchema = {
description: nls.localize('schema.file', 'The default file icon, shown for all files that don\'t match any extension, filename or language id.')

},
rootFolderNames: {
type: 'object',
description: nls.localize('schema.rootFolderNames', 'Associates root folder names to icons. The object key is the folder name, not including any path segments. No patterns or wildcards are allowed. Folder name matching is case insensitive.'),
additionalProperties: {
type: 'string',
description: nls.localize('schema.folderName', 'The ID of the icon definition for the association.')
}
},
rootFolderNamesExpanded: {
type: 'object',
description: nls.localize('schema.rootFolderNamesExpanded', 'Associates root folder names to icons for expanded folders. The object key is the folder name, not including any path segments. No patterns or wildcards are allowed. Folder name matching is case insensitive.'),
additionalProperties: {
type: 'string',
description: nls.localize('schema.folderNameExpanded', 'The ID of the icon definition for the association.')
}
},
folderNames: {
type: 'object',
description: nls.localize('schema.folderNames', 'Associates folder names to icons. The object key is the folder name, not including any path segments. No patterns or wildcards are allowed. Folder name matching is case insensitive.'),
Expand Down

0 comments on commit 2b9791e

Please sign in to comment.