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

Support VS System theme #74432

Merged
merged 6 commits into from
Jul 23, 2024
Merged

Support VS System theme #74432

merged 6 commits into from
Jul 23, 2024

Conversation

JoeRobich
Copy link
Member

The System theme has a unique ThemeId but reuses the editor colors from the Light and Dark themes. When the System theme is selected we will now check the registry to see whether Apps should be using the light theme and then apply the appropriate color scheme.

I also noticed while testing that VSColorTheme_ThemeChanged fires multiple times in a row when the Windows theme is changed. We only need to apply the color scheme colors once in response. I have added a field to track whether we have an update pending.

Resolves #74416

VSColorTheme_ThemeChanged fires multiple times in a row when the Windows theme is changed.  We only need to apply the color scheme colors once in response.
The System theme has a unique ThemeId but reuses the editor colors from the Light and Dark themes. When the System theme is selected we will check the registry to see whether Apps should be using the light theme and then apply the appropriate color scheme.
@JoeRobich JoeRobich requested a review from a team as a code owner July 18, 2024 06:14
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 18, 2024
@CyrusNajmabadi
Copy link
Member

We only need to apply the color scheme colors once in response. I have added a field to track whether we have an update pending.

Another way to handle this, which may be cleaner, is to use an AsyncBatchingWorkQueue to queue up the work. That way if there is a flurry of notifications, it will only end up causing one update to happen.

@JoeRobich
Copy link
Member Author

Another way to handle this, which may be cleaner, is to use an AsyncBatchingWorkQueue to queue up the work.

@CyrusNajmabadi Updated to use a work queue. Thanks for the suggestion.

@@ -56,6 +61,11 @@ internal sealed partial class ColorSchemeApplier
_settings = new ColorSchemeSettings(threadingContext, _serviceProvider, globalOptions);
_colorSchemes = ColorSchemeSettings.GetColorSchemes();
_classificationVerifier = new ClassificationVerifier(threadingContext, fontAndColorStorage, _colorSchemes);
_workQueue = new(
TimeSpan.FromMilliseconds(1000),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try DelayTimeSpan.Idle

Copy link
Member

@sharwell sharwell Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 It seems like Idle could leave a really strange visual state for 1.5 seconds, where Short would be equally effective but with less transition time.

@@ -56,6 +61,11 @@ internal sealed partial class ColorSchemeApplier
_settings = new ColorSchemeSettings(threadingContext, _serviceProvider, globalOptions);
_colorSchemes = ColorSchemeSettings.GetColorSchemes();
_classificationVerifier = new ClassificationVerifier(threadingContext, fontAndColorStorage, _colorSchemes);
_workQueue = new(
TimeSpan.FromMilliseconds(1000),
async (token) => await QueueColorSchemeUpdateAsync().ConfigureAwait(false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async (token) => await QueueColorSchemeUpdateAsync().ConfigureAwait(false),
async _ => await QueueColorSchemeUpdateAsync().ConfigureAwait(false),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, just replace this entirely with QueueColorSchemeUpdateAsync as the entire argument.

TimeSpan.FromMilliseconds(1000),
async (token) => await QueueColorSchemeUpdateAsync().ConfigureAwait(false),
listenerProvider.GetListener(FeatureAttribute.ColorScheme),
CancellationToken.None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CancellationToken.None);
threadingContext.DisposalToken);

{
_workQueue.AddWork();
return Task.CompletedTask;
}

private async Task QueueColorSchemeUpdateAsync()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private async Task QueueColorSchemeUpdateAsync()
private async ValueTask QueueColorSchemeUpdateAsync(CancellationToken cancellationToken)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, use thei cancellationToken in the StartOnIdle call below.

@CyrusNajmabadi
Copy link
Member

LMK when you make the changes, and i'll quickly review.

@JoeRobich
Copy link
Member Author

@CyrusNajmabadi That cleaned up nicely. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax highlight colors differ between Dark and System modes
4 participants