Skip to content

Commit e6470a9

Browse files
author
Benjamin Pasero
committed
screen cheese while previewing icon theme (fix microsoft#99032)
1 parent 459b50e commit e6470a9

5 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/vs/workbench/browser/parts/editor/editor.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { localize } from 'vs/nls';
67
import { GroupIdentifier, IWorkbenchEditorConfiguration, EditorOptions, TextEditorOptions, IEditorInput, IEditorIdentifier, IEditorCloseEvent, IEditorPane, IEditorPartOptions, IEditorPartOptionsChangeEvent, EditorInput } from 'vs/workbench/common/editor';
78
import { EditorGroup } from 'vs/workbench/common/editor/editorGroup';
89
import { IEditorGroup, GroupDirection, IAddGroupOptions, IMergeGroupOptions, GroupsOrder, GroupsArrangement, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
910
import { IDisposable } from 'vs/base/common/lifecycle';
1011
import { Dimension } from 'vs/base/browser/dom';
1112
import { Event } from 'vs/base/common/event';
12-
import { IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
13+
import { IConfigurationChangeEvent, IConfigurationService } from 'vs/platform/configuration/common/configuration';
14+
import { IThemeService } from 'vs/platform/theme/common/themeService';
1315
import { ISerializableView } from 'vs/base/browser/ui/grid/grid';
1416
import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
1517
import { IEditorOptions } from 'vs/platform/editor/common/editor';
1618
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';
17-
import { localize } from 'vs/nls';
1819

1920
export const EDITOR_TITLE_HEIGHT = 35;
2021

@@ -33,12 +34,12 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
3334
titleScrollbarSizing: 'default',
3435
focusRecentEditorAfterClose: true,
3536
showIcons: true,
37+
hasIcons: true, // 'vs-seti' is our default icon theme
3638
enablePreview: true,
3739
openPositioning: 'right',
3840
openSideBySideDirection: 'right',
3941
closeEmptyGroups: true,
4042
labelFormat: 'default',
41-
iconTheme: 'vs-seti',
4243
splitSizing: 'distribute'
4344
};
4445

@@ -66,16 +67,14 @@ export function impactsEditorPartOptions(event: IConfigurationChangeEvent): bool
6667
return event.affectsConfiguration('workbench.editor') || event.affectsConfiguration('workbench.iconTheme');
6768
}
6869

69-
export function getEditorPartOptions(config: IWorkbenchEditorConfiguration): IEditorPartOptions {
70-
const options = { ...DEFAULT_EDITOR_PART_OPTIONS };
71-
72-
if (!config || !config.workbench) {
73-
return options;
74-
}
75-
76-
options.iconTheme = config.workbench.iconTheme;
70+
export function getEditorPartOptions(configurationService: IConfigurationService, themeService: IThemeService): IEditorPartOptions {
71+
const options = {
72+
...DEFAULT_EDITOR_PART_OPTIONS,
73+
hasIcons: themeService.getFileIconTheme().hasFileIcons
74+
};
7775

78-
if (config.workbench.editor) {
76+
const config = configurationService.getValue<IWorkbenchEditorConfiguration>();
77+
if (config?.workbench?.editor) {
7978
Object.assign(options, config.workbench.editor);
8079
}
8180

src/vs/workbench/browser/parts/editor/editorPart.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { contrastBorder, editorBackground } from 'vs/platform/theme/common/color
1212
import { GroupDirection, IAddGroupOptions, GroupsArrangement, GroupOrientation, IMergeGroupOptions, MergeGroupMode, ICopyEditorOptions, GroupsOrder, GroupChangeKind, GroupLocation, IFindGroupScope, EditorGroupLayout, GroupLayoutArgument, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
1313
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1414
import { IView, orthogonal, LayoutPriority, IViewSize, Direction, SerializableGrid, Sizing, ISerializedGrid, Orientation, GridBranchNode, isGridBranchNode, GridNode, createSerializedGrid, Grid } from 'vs/base/browser/ui/grid/grid';
15-
import { GroupIdentifier, IWorkbenchEditorConfiguration, IEditorPartOptions, IEditorPartOptionsChangeEvent } from 'vs/workbench/common/editor';
15+
import { GroupIdentifier, IEditorPartOptions, IEditorPartOptionsChangeEvent } from 'vs/workbench/common/editor';
1616
import { EDITOR_GROUP_BORDER, EDITOR_PANE_BACKGROUND } from 'vs/workbench/common/theme';
1717
import { distinct, coalesce } from 'vs/base/common/arrays';
1818
import { IEditorGroupsAccessor, IEditorGroupView, getEditorPartOptions, impactsEditorPartOptions, IEditorPartCreationOptions } from 'vs/workbench/browser/parts/editor/editor';
@@ -149,7 +149,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
149149

150150
this.gridWidgetView = new GridWidgetView<IEditorGroupView>();
151151

152-
this._partOptions = getEditorPartOptions(this.configurationService.getValue<IWorkbenchEditorConfiguration>());
152+
this._partOptions = getEditorPartOptions(this.configurationService, this.themeService);
153153

154154
this.workspaceMemento = this.getMemento(StorageScope.WORKSPACE);
155155
this.globalMemento = this.getMemento(StorageScope.GLOBAL);
@@ -161,6 +161,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
161161

162162
private registerListeners(): void {
163163
this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
164+
this._register(this.themeService.onDidFileIconThemeChange(() => this.handleChangedPartOptions()));
164165
}
165166

166167
private onConfigurationUpdated(event: IConfigurationChangeEvent): void {
@@ -171,7 +172,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
171172

172173
private handleChangedPartOptions(): void {
173174
const oldPartOptions = this._partOptions;
174-
const newPartOptions = getEditorPartOptions(this.configurationService.getValue<IWorkbenchEditorConfiguration>());
175+
const newPartOptions = getEditorPartOptions(this.configurationService, this.themeService);
175176

176177
this.enforcedPartOptions.forEach(enforcedPartOptions => {
177178
Object.assign(newPartOptions, enforcedPartOptions); // check for overrides

src/vs/workbench/browser/parts/editor/media/tabstitlecontrol.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
padding-left: 10px;
6363
}
6464

65-
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sizing-shrink.has-icon-theme.close-button-right,
66-
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sizing-shrink.has-icon-theme.close-button-off:not(.sticky) {
65+
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sizing-shrink.has-icon.close-button-right,
66+
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sizing-shrink.has-icon.close-button-off:not(.sticky) {
6767
padding-left: 5px; /* reduce padding when we show icons and are in shrinking mode and tab close button is not left (unless sticky) */
6868
}
6969

@@ -198,7 +198,7 @@
198198
opacity: 0; /* when tab has the focus this shade breaks the tab border (fixes https://github.com/Microsoft/vscode/issues/57819) */
199199
}
200200

201-
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sticky:not(.has-icon-theme) .monaco-icon-label {
201+
.monaco-workbench .part.editor > .content .editor-group-container > .title .tabs-container > .tab.sticky:not(.has-icon) .monaco-icon-label {
202202
text-align: center; /* ensure that sticky tabs without icon have label centered */
203203
}
204204

src/vs/workbench/browser/parts/editor/tabsTitleControl.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ export class TabsTitleControl extends TitleControl {
522522
oldOptions.tabCloseButton !== newOptions.tabCloseButton ||
523523
oldOptions.tabSizing !== newOptions.tabSizing ||
524524
oldOptions.showIcons !== newOptions.showIcons ||
525-
oldOptions.iconTheme !== newOptions.iconTheme ||
525+
oldOptions.hasIcons !== newOptions.hasIcons ||
526526
oldOptions.highlightModifiedTabs !== newOptions.highlightModifiedTabs
527527
) {
528528
this.redraw();
@@ -1033,10 +1033,10 @@ export class TabsTitleControl extends TitleControl {
10331033
domAction(tabContainer, `sizing-${option}`);
10341034
});
10351035

1036-
if (options.showIcons && !!options.iconTheme) {
1037-
addClass(tabContainer, 'has-icon-theme');
1036+
if (options.showIcons && options.hasIcons) {
1037+
addClass(tabContainer, 'has-icon');
10381038
} else {
1039-
removeClass(tabContainer, 'has-icon-theme');
1039+
removeClass(tabContainer, 'has-icon');
10401040
}
10411041

10421042
// Sticky Tabs need a position to remain at their location
@@ -1062,7 +1062,7 @@ export class TabsTitleControl extends TitleControl {
10621062
let name: string | undefined;
10631063
let description: string;
10641064
if (isTabSticky) {
1065-
const isShowingIcons = this.accessor.partOptions.showIcons && !!this.accessor.partOptions.iconTheme;
1065+
const isShowingIcons = this.accessor.partOptions.showIcons && this.accessor.partOptions.hasIcons;
10661066
name = isShowingIcons ? '' : tabLabel.name?.charAt(0).toUpperCase();
10671067
description = '';
10681068
} else {

src/vs/workbench/common/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ interface IEditorPartConfiguration {
12021202
}
12031203

12041204
export interface IEditorPartOptions extends IEditorPartConfiguration {
1205-
iconTheme?: string;
1205+
hasIcons?: boolean;
12061206
}
12071207

12081208
export interface IEditorPartOptionsChangeEvent {

0 commit comments

Comments
 (0)