-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Support VS System theme #74432
Conversation
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.
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. |
@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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try DelayTimeSpan.Idle
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async (token) => await QueueColorSchemeUpdateAsync().ConfigureAwait(false), | |
async _ => await QueueColorSchemeUpdateAsync().ConfigureAwait(false), |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CancellationToken.None); | |
threadingContext.DisposalToken); |
{ | ||
_workQueue.AddWork(); | ||
return Task.CompletedTask; | ||
} | ||
|
||
private async Task QueueColorSchemeUpdateAsync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private async Task QueueColorSchemeUpdateAsync() | |
private async ValueTask QueueColorSchemeUpdateAsync(CancellationToken cancellationToken) |
There was a problem hiding this comment.
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.
LMK when you make the changes, and i'll quickly review. |
@CyrusNajmabadi That cleaned up nicely. Thanks! |
Co-authored-by: Cyrus Najmabadi <[email protected]>
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