-
Notifications
You must be signed in to change notification settings - Fork 234
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
fix: cache color profile and background #212
Conversation
Guard accessing the underlying Termenv output behind a mutex. Multiple goroutines can set/get the dark background color causing a race condition. Needs: muesli/termenv#146
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.
2 questions, but looks good to me
|
||
if !r.explicitColorProfile { | ||
r.getColorProfile.Do(func() { | ||
r.colorProfile = r.output.EnvColorProfile() |
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.
should it wlock here?
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 looks like we do, but I think we don't need to since the function would only run once. Maybe @muesli can weigh on this
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.
Agree, the sync.Once
already provides its own locking mechanism, so the read-lock should be sufficient. Could maybe add a comment in that regard to prevent further confusion.
|
||
if !r.explicitBackgroundColor { | ||
r.getBackgroundColor.Do(func() { | ||
r.hasDarkBackground = r.output.HasDarkBackground() |
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.
should it wlock here?
Add `SetColorProfile` to force change the Lip Gloss renderer color profile. Needs: charmbracelet/lipgloss#212 Fixes: #63
Add `SetColorProfile` to force change the Lip Gloss renderer color profile. Needs: charmbracelet/lipgloss#212 Fixes: #63
Add `SetColorProfile` to force change the Lip Gloss renderer color profile. Needs: charmbracelet/lipgloss#212 Fixes: #63
Reintroduce caching the color profile and background