Skip to content

Commit 994eaad

Browse files
committed
Move icon theme down to editor/platform. Fixes microsoft#61031
1 parent faf868e commit 994eaad

7 files changed

Lines changed: 72 additions & 18 deletions

File tree

src/vs/editor/standalone/browser/standaloneThemeServiceImpl.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as dom from 'vs/base/browser/dom';
1010
import { TokenizationRegistry } from 'vs/editor/common/modes';
1111
import { Color } from 'vs/base/common/color';
1212
import { Extensions, IColorRegistry, ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
13-
import { Extensions as ThemingExtensions, IThemingRegistry, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
13+
import { Extensions as ThemingExtensions, IThemingRegistry, ICssStyleCollector, IIconTheme } from 'vs/platform/theme/common/themeService';
1414
import { Registry } from 'vs/platform/registry/common/platform';
1515
import { Event, Emitter } from 'vs/base/common/event';
1616
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
@@ -163,10 +163,12 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
163163
private _styleElement: HTMLStyleElement;
164164
private _theme: IStandaloneTheme;
165165
private readonly _onThemeChange: Emitter<IStandaloneTheme>;
166+
private readonly _onIconThemeChange: Emitter<IIconTheme>;
166167
private environment: IEnvironmentService = Object.create(null);
167168

168169
constructor() {
169170
this._onThemeChange = new Emitter<IStandaloneTheme>();
171+
this._onIconThemeChange = new Emitter<IIconTheme>();
170172

171173
this._knownThemes = new Map<string, StandaloneTheme>();
172174
this._knownThemes.set(VS_THEME_NAME, newBuiltInTheme(VS_THEME_NAME));
@@ -239,4 +241,16 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
239241

240242
return theme.id;
241243
}
244+
245+
public getIconTheme(): IIconTheme {
246+
return {
247+
hasFileIcons: false,
248+
hasFolderIcons: false,
249+
hidesExplorerArrows: false
250+
};
251+
}
252+
253+
public get onIconThemeChange(): Event<IIconTheme> {
254+
return this._onIconThemeChange.event;
255+
}
242256
}

src/vs/editor/standalone/test/browser/standaloneLanguages.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import * as assert from 'assert';
66
import { TokenizationSupport2Adapter, TokensProvider, ILineTokens, IToken } from 'vs/editor/standalone/browser/standaloneLanguages';
77
import { IStandaloneThemeService, IStandaloneThemeData, IStandaloneTheme } from 'vs/editor/standalone/common/standaloneThemeService';
8-
import { Event } from 'vs/base/common/event';
9-
import { ITheme, LIGHT } from 'vs/platform/theme/common/themeService';
8+
import { Emitter } from 'vs/base/common/event';
9+
import { ITheme, LIGHT, IIconTheme } from 'vs/platform/theme/common/themeService';
1010
import { LanguageIdentifier, LanguageId, IState, MetadataConsts } from 'vs/editor/common/modes';
1111
import { Token } from 'vs/editor/common/core/token';
1212
import { TokenTheme } from 'vs/editor/common/modes/supports/tokenization';
@@ -56,7 +56,15 @@ suite('TokenizationSupport2Adapter', () => {
5656
}
5757
};
5858
}
59-
public readonly onThemeChange: Event<ITheme> | null = null;
59+
public getIconTheme(): IIconTheme {
60+
return {
61+
hasFileIcons: false,
62+
hasFolderIcons: false,
63+
hidesExplorerArrows: false
64+
};
65+
}
66+
public readonly onThemeChange = new Emitter<ITheme>().event;
67+
public readonly onIconThemeChange = new Emitter<IIconTheme>().event;
6068
}
6169

6270
class MockState implements IState {

src/vs/platform/theme/common/themeService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export interface ITheme {
6161
defines(color: ColorIdentifier): boolean;
6262
}
6363

64+
export interface IIconTheme {
65+
readonly hasFileIcons: boolean;
66+
readonly hasFolderIcons: boolean;
67+
readonly hidesExplorerArrows: boolean;
68+
}
69+
6470
export interface ICssStyleCollector {
6571
addRule(rule: string): void;
6672
}
@@ -74,10 +80,11 @@ export interface IThemeService {
7480

7581
getTheme(): ITheme;
7682

77-
/**
78-
* Register a theming participant that is invoked after every theme change.
79-
*/
80-
onThemeChange: Event<ITheme>;
83+
readonly onThemeChange: Event<ITheme>;
84+
85+
getIconTheme(): IIconTheme;
86+
87+
readonly onIconThemeChange: Event<IIconTheme>;
8188

8289
}
8390

src/vs/platform/theme/test/common/testThemeService.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Event, Emitter } from 'vs/base/common/event';
7-
import { IThemeService, ITheme, DARK } from 'vs/platform/theme/common/themeService';
7+
import { IThemeService, ITheme, DARK, IIconTheme } from 'vs/platform/theme/common/themeService';
88
import { Color } from 'vs/base/common/color';
99

1010
export class TestTheme implements ITheme {
@@ -25,14 +25,23 @@ export class TestTheme implements ITheme {
2525
}
2626
}
2727

28+
export class TestIconTheme implements IIconTheme {
29+
hasFileIcons = false;
30+
hasFolderIcons = false;
31+
hidesExplorerArrows = false;
32+
}
33+
2834
export class TestThemeService implements IThemeService {
2935

3036
_serviceBrand: any;
3137
_theme: ITheme;
38+
_iconTheme: IIconTheme;
3239
_onThemeChange = new Emitter<ITheme>();
40+
_onIconThemeChange = new Emitter<IIconTheme>();
3341

34-
constructor(theme = new TestTheme()) {
42+
constructor(theme = new TestTheme(), iconTheme = new TestIconTheme()) {
3543
this._theme = theme;
44+
this._iconTheme = iconTheme;
3645
}
3746

3847
getTheme(): ITheme {
@@ -51,4 +60,12 @@ export class TestThemeService implements IThemeService {
5160
public get onThemeChange(): Event<ITheme> {
5261
return this._onThemeChange.event;
5362
}
63+
64+
getIconTheme(): IIconTheme {
65+
return this._iconTheme;
66+
}
67+
68+
public get onIconThemeChange(): Event<IIconTheme> {
69+
return this._onIconThemeChange.event;
70+
}
5471
}

src/vs/workbench/services/themes/common/workbenchThemeService.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
77
import { Event } from 'vs/base/common/event';
88
import { Color } from 'vs/base/common/color';
9-
import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService';
9+
import { ITheme, IThemeService, IIconTheme } from 'vs/platform/theme/common/themeService';
1010
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
1111

1212
export const IWorkbenchThemeService = createDecorator<IWorkbenchThemeService>('themeService');
@@ -38,17 +38,17 @@ export interface IColorMap {
3838
[id: string]: Color;
3939
}
4040

41-
export interface IFileIconTheme {
41+
export interface IFileIconTheme extends IIconTheme {
4242
readonly id: string;
4343
readonly label: string;
4444
readonly settingsId: string;
4545
readonly description?: string;
4646
readonly extensionData: ExtensionData;
4747

4848
readonly isLoaded: boolean;
49-
readonly hasFileIcons?: boolean;
50-
readonly hasFolderIcons?: boolean;
51-
readonly hidesExplorerArrows?: boolean;
49+
readonly hasFileIcons: boolean;
50+
readonly hasFolderIcons: boolean;
51+
readonly hidesExplorerArrows: boolean;
5252
}
5353

5454
export interface IWorkbenchThemeService extends IThemeService {

src/vs/workbench/services/themes/electron-browser/fileIconThemeData.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class FileIconThemeData implements IFileIconTheme {
1717
label: string;
1818
settingsId: string;
1919
description?: string;
20-
hasFileIcons?: boolean;
21-
hasFolderIcons?: boolean;
22-
hidesExplorerArrows?: boolean;
20+
hasFileIcons: boolean;
21+
hasFolderIcons: boolean;
22+
hidesExplorerArrows: boolean;
2323
isLoaded: boolean;
2424
location?: URI;
2525
extensionData: ExtensionData;

src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
191191
return this.onFileIconThemeChange.event;
192192
}
193193

194+
public get onIconThemeChange(): Event<IFileIconTheme> {
195+
return this.onFileIconThemeChange.event;
196+
}
197+
194198
public get onThemeChange(): Event<ITheme> {
195199
return this.onColorThemeChange.event;
196200
}
@@ -394,6 +398,10 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
394398
return this.currentIconTheme;
395399
}
396400

401+
public getIconTheme() {
402+
return this.currentIconTheme;
403+
}
404+
397405
public setFileIconTheme(iconTheme: string, settingsTarget: ConfigurationTarget): Thenable<IFileIconTheme> {
398406
iconTheme = iconTheme || '';
399407
if (iconTheme === this.currentIconTheme.id && this.currentIconTheme.isLoaded) {

0 commit comments

Comments
 (0)