Skip to content

Commit

Permalink
preview themes also for built-in themes (#152885)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored Jun 22, 2022
1 parent 3997bb7 commit 7a9ac30
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/vs/workbench/contrib/themes/browser/themes.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { localize } from 'vs/nls';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { MenuRegistry, MenuId, Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { Registry } from 'vs/platform/registry/common/platform';
import { CATEGORIES } from 'vs/workbench/common/actions';
import { IWorkbenchThemeService, IWorkbenchTheme, ThemeSettingTarget, IWorkbenchColorTheme, IWorkbenchFileIconTheme, IWorkbenchProductIconTheme, ThemeSettings } from 'vs/workbench/services/themes/common/workbenchThemeService';
Expand Down Expand Up @@ -465,7 +466,10 @@ registerAction2(class extends Action2 {
CommandsRegistry.registerCommand('workbench.action.previewColorTheme', async function (accessor: ServicesAccessor, extension: { publisher: string; name: string; version: string }, themeSettingsId?: string) {
const themeService = accessor.get(IWorkbenchThemeService);

const themes = await themeService.getMarketplaceColorThemes(extension.publisher, extension.name, extension.version);
let themes = findBuiltInThemes(await themeService.getColorThemes(), extension);
if (themes.length === 0) {
themes = await themeService.getMarketplaceColorThemes(extension.publisher, extension.name, extension.version);
}
for (const theme of themes) {
if (!themeSettingsId || theme.settingsId === themeSettingsId) {
await themeService.setColorTheme(theme, 'preview');
Expand All @@ -475,6 +479,10 @@ CommandsRegistry.registerCommand('workbench.action.previewColorTheme', async fun
return undefined;
});

function findBuiltInThemes(themes: IWorkbenchColorTheme[], extension: { publisher: string; name: string }): IWorkbenchColorTheme[] {
return themes.filter(({ extensionData }) => extensionData && extensionData.extensionIsBuiltin && equalsIgnoreCase(extensionData.extensionPublisher, extension.publisher) && equalsIgnoreCase(extensionData.extensionName, extension.name));
}

function configurationEntries(label: string): QuickPickInput<ThemeItem>[] {
return [
{
Expand Down

0 comments on commit 7a9ac30

Please sign in to comment.