mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 15:40:41 -05:00
Refactored getIconClasses function to accept optional ThemeIcon parameter and updated its usage across multiple files
This commit is contained in:
@@ -10,10 +10,14 @@ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'
|
||||
import { ILanguageService } from 'vs/editor/common/languages/language';
|
||||
import { IModelService } from 'vs/editor/common/services/model';
|
||||
import { FileKind } from 'vs/platform/files/common/files';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
|
||||
const fileIconDirectoryRegex = /(?:\/|^)(?:([^\/]+)\/)?([^\/]+)$/;
|
||||
|
||||
export function getIconClasses(modelService: IModelService, languageService: ILanguageService, resource: uri | undefined, fileKind?: FileKind): string[] {
|
||||
export function getIconClasses(modelService: IModelService, languageService: ILanguageService, resource: uri | undefined, fileKind?: FileKind, icon?: ThemeIcon): string[] {
|
||||
if (icon) {
|
||||
return [`codicon-${icon.id}`, 'product-icon'];
|
||||
}
|
||||
|
||||
// we always set these base classes even if we do not have a path
|
||||
const classes = fileKind === FileKind.ROOT_FOLDER ? ['rootfolder-icon'] : fileKind === FileKind.FOLDER ? ['folder-icon'] : ['file-icon'];
|
||||
|
||||
@@ -579,11 +579,8 @@ class ResourceLabelWidget extends IconLabel {
|
||||
|
||||
if (this.options && !this.options.hideIcon) {
|
||||
if (!this.computedIconClasses) {
|
||||
if (this.options.icon) {
|
||||
this.computedIconClasses = [`codicon-${this.options.icon.id}`, 'product-icon'];
|
||||
} else {
|
||||
this.computedIconClasses = getIconClasses(this.modelService, this.languageService, resource, this.options.fileKind);
|
||||
}
|
||||
this.computedIconClasses = getIconClasses(this.modelService, this.languageService, resource, this.options.fileKind, this.options.icon);
|
||||
|
||||
}
|
||||
|
||||
iconLabelOptions.extraClasses = this.computedIconClasses.slice(0);
|
||||
|
||||
@@ -157,7 +157,7 @@ export abstract class BaseEditorQuickAccessProvider extends PickerQuickAccessPro
|
||||
return isDirty ? localize('entryAriaLabelDirty', "{0}, unsaved changes", nameAndDescription) : nameAndDescription;
|
||||
})(),
|
||||
description,
|
||||
iconClasses: getIconClasses(this.modelService, this.languageService, resource).concat(editor.getLabelExtraClasses()),
|
||||
iconClasses: getIconClasses(this.modelService, this.languageService, resource, undefined, editor.getIcon()).concat(editor.getLabelExtraClasses()),
|
||||
italic: !this.editorGroupService.getGroup(groupId)?.isPinned(editor),
|
||||
buttons: (() => {
|
||||
return [
|
||||
|
||||
@@ -951,6 +951,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
|
||||
let description: string | undefined = undefined;
|
||||
let isDirty: boolean | undefined = undefined;
|
||||
let extraClasses: string[];
|
||||
let icon: ThemeIcon | undefined = undefined;
|
||||
|
||||
if (isEditorInput(resourceOrEditor)) {
|
||||
resource = EditorResourceAccessor.getOriginalUri(resourceOrEditor);
|
||||
@@ -958,6 +959,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
|
||||
description = resourceOrEditor.getDescription();
|
||||
isDirty = resourceOrEditor.isDirty() && !resourceOrEditor.isSaving();
|
||||
extraClasses = resourceOrEditor.getLabelExtraClasses();
|
||||
icon = resourceOrEditor.getIcon();
|
||||
} else {
|
||||
resource = URI.isUri(resourceOrEditor) ? resourceOrEditor : resourceOrEditor.resource;
|
||||
label = basenameOrAuthority(resource);
|
||||
@@ -968,7 +970,7 @@ export class AnythingQuickAccessProvider extends PickerQuickAccessProvider<IAnyt
|
||||
|
||||
const labelAndDescription = description ? `${label} ${description}` : label;
|
||||
|
||||
const iconClassesValue = new Lazy(() => getIconClasses(this.modelService, this.languageService, resource).concat(extraClasses));
|
||||
const iconClassesValue = new Lazy(() => getIconClasses(this.modelService, this.languageService, resource, undefined, icon).concat(extraClasses));
|
||||
|
||||
const buttonsValue = new Lazy(() => {
|
||||
const openSideBySideDirection = configuration.openSideBySideDirection;
|
||||
|
||||
Reference in New Issue
Block a user