Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respond to theme updates for tree sitter #241326

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/editor/common/viewModel/viewModelImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ export class ViewModel extends Disposable implements IViewModel {
this._eventDispatcher.emitSingleViewEvent(new viewEvents.ViewTokensColorsChangedEvent());
}));

this._register(this._themeService.onDidColorThemeChange((theme) => {
this._register(this._themeService.onDidColorThemeChange((e) => {
this._invalidateDecorationsColorCache();
this._eventDispatcher.emitSingleViewEvent(new viewEvents.ViewThemeChangedEvent(theme));
this._eventDispatcher.emitSingleViewEvent(new viewEvents.ViewThemeChangedEvent(e.theme));
}));

this._updateConfigurationViewLineCountNow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class ColorPickerHeader extends Disposable {
this._originalColorNode.style.backgroundColor = Color.Format.CSS.format(this.model.originalColor) || '';

this.backgroundColor = themeService.getColorTheme().getColor(editorHoverBackground) || Color.white;
this._register(themeService.onDidColorThemeChange(theme => {
this.backgroundColor = theme.getColor(editorHoverBackground) || Color.white;
this._register(themeService.onDidColorThemeChange(e => {
this.backgroundColor = e.theme.getColor(editorHoverBackground) || Color.white;
}));

this._register(dom.addDisposableListener(this._pickedColorNode, dom.EventType.CLICK, () => this.model.selectNextColorPresentation()));
Expand Down
8 changes: 6 additions & 2 deletions src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IMarker, IRelatedInformation, MarkerSeverity } from '../../../../platfo
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { SeverityIcon } from '../../../../platform/severityIcon/browser/severityIcon.js';
import { contrastBorder, editorBackground, editorErrorBorder, editorErrorForeground, editorInfoBorder, editorInfoForeground, editorWarningBorder, editorWarningForeground, oneOf, registerColor, transparent } from '../../../../platform/theme/common/colorRegistry.js';
import { IColorTheme, IThemeService } from '../../../../platform/theme/common/themeService.js';
import { IColorTheme, IThemeChangeEvent, IThemeService } from '../../../../platform/theme/common/themeService.js';

class MessageWidget {

Expand Down Expand Up @@ -255,11 +255,15 @@ export class MarkerNavigationWidget extends PeekViewWidget {
this._backgroundColor = Color.white;

this._applyTheme(_themeService.getColorTheme());
this._callOnDispose.add(_themeService.onDidColorThemeChange(this._applyTheme.bind(this)));
this._callOnDispose.add(_themeService.onDidColorThemeChange(this._ondDidColorThemeChange.bind(this)));

this.create();
}

private _ondDidColorThemeChange(e: IThemeChangeEvent) {
this._applyTheme(e.theme);
}

private _applyTheme(theme: IColorTheme) {
this._backgroundColor = theme.getColor(editorMarkerNavigationBackground);
let colorId = editorMarkerNavigationError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { IInstantiationService } from '../../../../../platform/instantiation/com
import { IKeybindingService } from '../../../../../platform/keybinding/common/keybinding.js';
import { ILabelService } from '../../../../../platform/label/common/label.js';
import { IWorkbenchAsyncDataTreeOptions, WorkbenchAsyncDataTree } from '../../../../../platform/list/browser/listService.js';
import { IColorTheme, IThemeService } from '../../../../../platform/theme/common/themeService.js';
import { IColorTheme, IThemeChangeEvent, IThemeService } from '../../../../../platform/theme/common/themeService.js';
import { FileReferences, OneReference, ReferencesModel } from '../referencesModel.js';
import { ITreeDragAndDrop, ITreeDragOverReaction } from '../../../../../base/browser/ui/tree/tree.js';
import { DataTransfers, IDragAndDropData } from '../../../../../base/browser/dnd.js';
Expand Down Expand Up @@ -276,7 +276,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true, supportOnTitleClick: true }, _instantiationService);

this._applyTheme(themeService.getColorTheme());
this._callOnDispose.add(themeService.onDidColorThemeChange(this._applyTheme.bind(this)));
this._callOnDispose.add(themeService.onDidColorThemeChange(this._onDidColorThemeChange.bind(this)));
this._peekViewService.addExclusiveWidget(editor, this);
this.create();
}
Expand All @@ -298,6 +298,10 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
super.dispose();
}

private _onDidColorThemeChange(e: IThemeChangeEvent): void {
this._applyTheme(e.theme);
}

private _applyTheme(theme: IColorTheme) {
const borderColor = theme.getColor(peekView.peekViewBorder) || Color.transparent;
this.style({
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/rename/browser/renameWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
}
}));

this._disposables.add(_themeService.onDidColorThemeChange(this._updateStyles, this));
this._disposables.add(_themeService.onDidColorThemeChange(e => this._updateStyles(e.theme)));
}

dispose(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/suggest/browser/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class SuggestWidget implements IDisposable {
const applyStatusBarStyle = () => this.element.domNode.classList.toggle('with-status-bar', this.editor.getOption(EditorOption.suggest).showStatusBar);
applyStatusBarStyle();

this._disposables.add(_themeService.onDidColorThemeChange(t => this._onThemeChange(t)));
this._disposables.add(_themeService.onDidColorThemeChange(t => this._onThemeChange(t.theme)));
this._onThemeChange(_themeService.getColorTheme());

this._disposables.add(this._list.onMouseDown(e => this._onListMouseDownOrTap(e)));
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/standalone/browser/standaloneThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { hc_black, hc_light, vs, vs_dark } from '../common/themes.js';
import { IEnvironmentService } from '../../../platform/environment/common/environment.js';
import { Registry } from '../../../platform/registry/common/platform.js';
import { asCssVariableName, ColorIdentifier, Extensions, IColorRegistry } from '../../../platform/theme/common/colorRegistry.js';
import { Extensions as ThemingExtensions, ICssStyleCollector, IFileIconTheme, IProductIconTheme, IThemingRegistry, ITokenStyle } from '../../../platform/theme/common/themeService.js';
import { Extensions as ThemingExtensions, ICssStyleCollector, IFileIconTheme, IProductIconTheme, IThemingRegistry, ITokenStyle, IThemeChangeEvent } from '../../../platform/theme/common/themeService.js';
import { IDisposable, Disposable } from '../../../base/common/lifecycle.js';
import { ColorScheme, isDark, isHighContrast } from '../../../platform/theme/common/theme.js';
import { getIconsStyleSheet, UnthemedProductIconTheme } from '../../../platform/theme/browser/iconsStyleSheet.js';
Expand Down Expand Up @@ -213,7 +213,7 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe

declare readonly _serviceBrand: undefined;

private readonly _onColorThemeChange = this._register(new Emitter<IStandaloneTheme>());
private readonly _onColorThemeChange = this._register(new Emitter<IThemeChangeEvent>());
public readonly onDidColorThemeChange = this._onColorThemeChange.event;

private readonly _onFileIconThemeChange = this._register(new Emitter<IFileIconTheme>());
Expand Down Expand Up @@ -403,7 +403,7 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe
this._updateCSS();

TokenizationRegistry.setColorMap(colorMap);
this._onColorThemeChange.fire(this._theme);
this._onColorThemeChange.fire({ theme: this._theme });
}

private _updateCSS(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IStandaloneTheme, IStandaloneThemeData, IStandaloneThemeService } from
import { UnthemedProductIconTheme } from '../../../../platform/theme/browser/iconsStyleSheet.js';
import { ColorIdentifier } from '../../../../platform/theme/common/colorRegistry.js';
import { ColorScheme } from '../../../../platform/theme/common/theme.js';
import { IColorTheme, IFileIconTheme, IProductIconTheme, ITokenStyle } from '../../../../platform/theme/common/themeService.js';
import { IFileIconTheme, IProductIconTheme, IThemeChangeEvent, ITokenStyle } from '../../../../platform/theme/common/themeService.js';

suite('TokenizationSupport2Adapter', () => {

Expand Down Expand Up @@ -92,7 +92,7 @@ suite('TokenizationSupport2Adapter', () => {
public getProductIconTheme(): IProductIconTheme {
return this._builtInProductIconTheme;
}
public readonly onDidColorThemeChange = new Emitter<IColorTheme>().event;
public readonly onDidColorThemeChange = new Emitter<IThemeChangeEvent>().event;
public readonly onDidFileIconThemeChange = new Emitter<IFileIconTheme>().event;
public readonly onDidProductIconThemeChange = new Emitter<IProductIconTheme>().event;
}
Expand Down
6 changes: 4 additions & 2 deletions src/vs/platform/theme/common/themeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ export interface IThemingParticipant {
(theme: IColorTheme, collector: ICssStyleCollector, environment: IEnvironmentService): void;
}

export type IThemeChangeEvent = { theme: IColorTheme };

export interface IThemeService {
readonly _serviceBrand: undefined;

getColorTheme(): IColorTheme;

readonly onDidColorThemeChange: Event<IColorTheme>;
readonly onDidColorThemeChange: Event<IThemeChangeEvent>;

getFileIconTheme(): IFileIconTheme;

Expand Down Expand Up @@ -182,7 +184,7 @@ export class Themable extends Disposable {
this.theme = themeService.getColorTheme();

// Hook up to theme changes
this._register(this.themeService.onDidColorThemeChange(theme => this.onThemeChange(theme)));
this._register(this.themeService.onDidColorThemeChange(e => this.onThemeChange(e.theme)));
}

protected onThemeChange(theme: IColorTheme): void {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/platform/theme/test/common/testThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Color } from '../../../../base/common/color.js';
import { Emitter, Event } from '../../../../base/common/event.js';
import { IconContribution } from '../../common/iconRegistry.js';
import { ColorScheme } from '../../common/theme.js';
import { IColorTheme, IFileIconTheme, IProductIconTheme, IThemeService, ITokenStyle } from '../../common/themeService.js';
import { IColorTheme, IFileIconTheme, IProductIconTheme, IThemeChangeEvent, IThemeService, ITokenStyle } from '../../common/themeService.js';

export class TestColorTheme implements IColorTheme {

Expand Down Expand Up @@ -58,7 +58,7 @@ export class TestThemeService implements IThemeService {
_colorTheme: IColorTheme;
_fileIconTheme: IFileIconTheme;
_productIconTheme: IProductIconTheme;
_onThemeChange = new Emitter<IColorTheme>();
_onThemeChange = new Emitter<IThemeChangeEvent>();
_onFileIconThemeChange = new Emitter<IFileIconTheme>();
_onProductIconThemeChange = new Emitter<IProductIconTheme>();

Expand All @@ -78,10 +78,10 @@ export class TestThemeService implements IThemeService {
}

fireThemeChange() {
this._onThemeChange.fire(this._colorTheme);
this._onThemeChange.fire({ theme: this._colorTheme });
}

public get onDidColorThemeChange(): Event<IColorTheme> {
public get onDidColorThemeChange(): Event<IThemeChangeEvent> {
return this._onThemeChange.event;
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/compositeBarActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { $, addDisposableListener, append, clearNode, EventHelper, EventType, ge
import { ICommandService } from '../../../platform/commands/common/commands.js';
import { toDisposable, DisposableStore, MutableDisposable } from '../../../base/common/lifecycle.js';
import { IContextMenuService } from '../../../platform/contextview/browser/contextView.js';
import { IThemeService, IColorTheme } from '../../../platform/theme/common/themeService.js';
import { IThemeService, IColorTheme, IThemeChangeEvent } from '../../../platform/theme/common/themeService.js';
import { NumberBadge, IBadge, IActivity, ProgressBadge, IconBadge } from '../../services/activity/common/activity.js';
import { IInstantiationService, ServicesAccessor } from '../../../platform/instantiation/common/instantiation.js';
import { DelayedDragHandler } from '../../../base/browser/dnd.js';
Expand Down Expand Up @@ -289,7 +289,7 @@ export class CompositeBarActionViewItem extends BaseActionViewItem {
this.updateTitle();
}

private onThemeChange(theme: IColorTheme): void {
private onThemeChange(theme: IThemeChangeEvent): void {
this.updateStyles();
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/statusbar/statusbarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ export class StatusbarEntryItem extends Disposable {
if (isThemeColor(color)) {
colorResult = this.themeService.getColorTheme().getColor(color.id)?.toString();

const listener = this.themeService.onDidColorThemeChange(theme => {
const colorValue = theme.getColor(color.id)?.toString();
const listener = this.themeService.onDidColorThemeChange(e => {
const colorValue = e.theme.getColor(color.id)?.toString();

if (isBackground) {
container.style.backgroundColor = colorValue ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class CallHierarchyTreePeekWidget extends peekView.PeekViewWidget {
this.create();
this._peekViewService.addExclusiveWidget(editor, this);
this._applyTheme(themeService.getColorTheme());
this._disposables.add(themeService.onDidColorThemeChange(this._applyTheme, this));
this._disposables.add(themeService.onDidColorThemeChange(e => this._applyTheme(e.theme)));
this._disposables.add(this._previewDisposable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
this._commentThreadDisposables = [];
this.create();

this._globalToDispose.add(this.themeService.onDidColorThemeChange(this._applyTheme, this));
this._globalToDispose.add(this.themeService.onDidColorThemeChange(e => this._applyTheme(e.theme)));
this._globalToDispose.add(this.editor.onDidChangeConfiguration(e => {
if (e.hasChanged(EditorOption.fontInfo)) {
this._applyTheme(this.themeService.getColorTheme());
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/debug/browser/disassemblyView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ class InstructionRenderer extends Disposable implements ITableRenderer<IDisassem
this._focusedStackFrameColor = themeService.getColorTheme().getColor(focusedStackFrameColor);

this._register(themeService.onDidColorThemeChange(e => {
this._topStackFrameColor = e.getColor(topStackFrameColor);
this._focusedStackFrameColor = e.getColor(focusedStackFrameColor);
this._topStackFrameColor = e.theme.getColor(topStackFrameColor);
this._focusedStackFrameColor = e.theme.getColor(focusedStackFrameColor);
}));
}

Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/contrib/debug/browser/exceptionWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ZoneWidget } from '../../../../editor/contrib/zoneWidget/browser/zoneWi
import { ICodeEditor } from '../../../../editor/browser/editorBrowser.js';
import { IExceptionInfo, IDebugSession, IDebugEditorContribution, EDITOR_CONTRIBUTION_ID } from '../common/debug.js';
import { RunOnceScheduler } from '../../../../base/common/async.js';
import { IThemeService, IColorTheme } from '../../../../platform/theme/common/themeService.js';
import { IThemeService, IColorTheme, IThemeChangeEvent } from '../../../../platform/theme/common/themeService.js';
import { ThemeIcon } from '../../../../base/common/themables.js';
import { Color } from '../../../../base/common/color.js';
import { registerColor } from '../../../../platform/theme/common/colorRegistry.js';
Expand Down Expand Up @@ -41,14 +41,18 @@ export class ExceptionWidget extends ZoneWidget {
super(editor, { showFrame: true, showArrow: true, isAccessible: true, frameWidth: 1, className: 'exception-widget-container' });

this.applyTheme(themeService.getColorTheme());
this._disposables.add(themeService.onDidColorThemeChange(this.applyTheme.bind(this)));
this._disposables.add(themeService.onDidColorThemeChange(this.onDidColorThemeChange.bind(this)));

this.create();
const onDidLayoutChangeScheduler = new RunOnceScheduler(() => this._doLayout(undefined, undefined), 50);
this._disposables.add(this.editor.onDidLayoutChange(() => onDidLayoutChangeScheduler.schedule()));
this._disposables.add(onDidLayoutChangeScheduler);
}

private onDidColorThemeChange(e: IThemeChangeEvent): void {
this.applyTheme(e.theme);
}

private applyTheme(theme: IColorTheme): void {
this.backgroundColor = theme.getColor(debugExceptionWidgetBackground);
const frameColor = theme.getColor(debugExceptionWidgetBorder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class NotebookDiffOverviewRuler extends Themable {
}));

this._register(this.themeService.onDidColorThemeChange(e => {
const colorChanged = this.applyColors(e);
const colorChanged = this.applyColors(e.theme);
if (colorChanged) {
this._scheduleRender();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/quickDiffWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class QuickDiffWidget extends PeekViewWidget {
) {
super(editor, { isResizeable: true, frameWidth: 1, keepEditorSelection: true, className: 'dirty-diff' }, instantiationService);

this._disposables.add(themeService.onDidColorThemeChange(this._applyTheme, this));
this._disposables.add(themeService.onDidColorThemeChange(e => this._applyTheme(e.theme)));
this._applyTheme(themeService.getColorTheme());

if (!Iterable.isEmpty(this.model.originalTextModels)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
}
}));

this._register(this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme)));
this._register(this._themeService.onDidColorThemeChange(e => this._updateTheme(e.theme)));
this._register(this._logService.onDidChangeLogLevel(e => this.raw.options.logLevel = vscodeToXtermLogLevel(e)));

// Refire events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class TypeHierarchyTreePeekWidget extends peekView.PeekViewWidget {
this.create();
this._peekViewService.addExclusiveWidget(editor, this);
this._applyTheme(themeService.getColorTheme());
this._disposables.add(themeService.onDidColorThemeChange(this._applyTheme, this));
this._disposables.add(themeService.onDidColorThemeChange(e => this._applyTheme(e.theme), this));
this._disposables.add(this._previewDisposable);
}

Expand Down
Loading
Loading