-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Loading palette or spec before colorscheme disrupts colors #362
Labels
bug
Something isn't working
Comments
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 8, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 8, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 8, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 8, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 9, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 9, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 9, 2024
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 9, 2024
Fix bug where the colorscheme colors are off/incorrect when a palette is require()'d, whether directly or indirectly, anytime before compilation occurs (e.g. compilation that occurs during colorscheme load). For details, see issue projekt0n#362. Also, add a test (in `test/`) which disallows the direct or indirect use of the global static/class fields of the `Color` class (e.g. `Color.BG`). Fixes: projekt0n#362
tmillr
added a commit
to tmillr/github-nvim-theme
that referenced
this issue
Aug 9, 2024
Fix bug where the colorscheme colors are off/incorrect when a palette is require()'d, whether directly or indirectly, anytime before compilation occurs (e.g. compilation that occurs during colorscheme load). For details, see issue projekt0n#362. Also, add a test (in `test/`) which disallows the direct or indirect use of the global static/class fields of the `Color` class (e.g. `Color.BG`). Fixes: projekt0n#362
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Basically if (as a user) you
require()
the palette before loading the colorscheme, then you load the colorscheme, some of the colors will be off and will be different than if you had never required/loaded the palette.Explanation
I've mentioned this bug before (where it was affecting the colors of my Airline status-line: see the comments on #290) and it has to do with:
:alpha_blend()
), use of the global-ish static/class properties of theColor
class (i.e.Color.{WHITE,BLACK,BG}
)lua/github-theme/palette/*.lua
)require()
's each and every theme's palette file consecutively.The colors affected will be any color which depends on the aforementioned static properties (e.g. any color using
alpha_blend()
that is not defined at the top-level of a palette file).All that's needed to trigger the bug is to directly or indirectly require a palette prior to compiling. Since the global/static
Color.*
fields are set at the top-level of each palette file, and since previously-required files are cached in Lua, they only get set once the first time a palette is required. Later, when the colorscheme is loaded and a compilation happens, these fields won't be set again for the themes whose palette was previously-required (cached) (but they will be set for/by non-previously-required palettes). So, when the palette/spec that the user required is then loaded by the colorscheme (during compilation), it will use incorrect values forColor.{WHITE,BLACK,BG}
(which will still be set to whatever the last non-cached palette file set them to). Hopefully that all makes sense.Solution
There's probably different ways to solve this, but I think we ought to go about this by simply stopping the internal use
Color.{WHITE,BLACK,BG}
andalpha_blend()
altogether (both now, and in the future). Using these shared, global, static/class fields ofColor
, it's just too easy to shoot ourselves in the foot and cause bugs (and bugs which are hard to track-down, and even hard to describe), and requiring a palette file should not have side effects like this. The only question is whether we leave them defined for users for convenience, although they can run into similar issues (e.g. by depending on those fields and falsely assuming that they are set to correct values before the colorscheme has been loaded).The text was updated successfully, but these errors were encountered: