Add hotkeys and actions for toggle light and dark theme#49027
Add hotkeys and actions for toggle light and dark theme#49027SomeoneToIgnore merged 19 commits intozed-industries:mainfrom
Conversation
|
@SomeoneToIgnore seems orchestrate fails due to the branch of this PR is too far behind, lemme rebase from main within today. 🙏 |
3f79d85 to
9ad171d
Compare
|
@SomeoneToIgnore just finished rebase, please activate the workflow again, thanks! |
|
about the clippy and test check, may I know if the workflow has changed recently? since I run |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Overall, looking at the PR, I am not sure about the amount of actions to add: would it be better if we could have an action that toggles theme modes (first, if needed, switches into the mode that allows toggling first)?
If we go this way, it might also better be tested in editor_tests.rs instead of the current settings-related change?
The flow you suggested seems better, when in static, you only have option to switch to dynamic mode. While in dynamic mode, you can choose system, light, dark, or switch back to static. Does that sounds good? |
|
Do we really need the "back to static" thing? |
|
I would say this is completely new and not seen in other IDE/text editors. I checked VSCode, Xcode, and Android Studio, they dont have a shortcut to manually switch between light, dark or system. The only have shortcut to open color theme selector, which is the same thing as theme selector in Zed. "back to static" is prob like a edge-case handling for me. e.g. maybe the user just wants the single theme, instead of switching between light and dark or following the system, which changes themes when sunrise/sunset. Side trackAbout Static and Dynamic Theme Mode, I am not sure if we really need that much level of customization. The IDEs I checked on, they are mostly working with single theme selection box, plus a option to sync with OS, thats all. As my personal experience, I mainly just pick a theme I am familiar with e.g. material, one dark, xcode default dark, then I mostly wont touch that part anymore. While keeping light theme is also reasonable, mostly I would expect they are in pairs with the dark theme. If possible, I would like to make themes into optional theme pairs, and replace dynamic mode with "sync with OS" option. But that's definitely not this PR. This PR just aims to provide more flexibility on switching themes Lemme know what you think. |
Maybe there's no shortcut, but there's definitely an action in VSCode: vscode_theme_toggle.movAnd I suspect that's what people want, really, at least now in that discussion: no dynamic/static switch, just dark/bright theme switching. I would start with that, but lack good context on the modes right now: presumably, we'll have to consider switching the mode once when toggling, but overall what we have to do is to toggle between dark/bright and persist that choice + have tests for all modes for this. |
ahhhh so it is in preferences, no wonder I cannot found it lol.
But in order to adapt with the current appearance settings, system mode needs to be catered also(which means we cannot do the toggle just like VSCode). And this is the intention why I separate them into 3 independent actions and hotkeys. But I 100% agree we should keep it simple. |
|
Great, so this is the caveat I've missed, the system mode: to me, does not seem wrong to automatically convert such mode into something more suitable then (Static, it seems? not sure) and switch still. This can be documented so people have less surprises and sure, should be tested, as all other modes' switching. |
|
I am thinking, should we switch static to system in this PR, since my intention is to just extend the flexibility of switching themes using actions and shortcuts. I can do it in a separate PR to swap static mode out I guess...? |
|
From the user's perspective:
So, if we can add an action that gets us into this switching loop out of whatever related settings state + have it tested, we're good. |
|
you are correct, I got stuck into how to do things gracefully. Lemme implement it these 2 days! Thanks. |
|
I did some refactoring based on the discussion above:
|
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Great, we have some progress shaping, but now the changes are very odd: crates/settings/src/settings_store.rs's new code is not used anywhere but its new tests.
So, we still miss the tests on the crates/workspace/src/workspace.rs level (you can check out crates/editor/src/editor_tests.rs or tests in the workspace.rs module on how those are created).
|
lol typo on markdown, lemme update that real quick |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Nice, we're getting there.
Let's finally write a proper test that uses the editor's action, and we're good to merge.
default, mode as system. update documentation, remove excessive methods.
incorrect usage of GlobalTheme, now currently depends on theme observer.
2cfd4de to
6d661fb
Compare
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
We're getting there, but the test code is too LLM-esque and needs improvement.
workspace.rs, remove excessive test in settings_store.rs
|
@SomeoneToIgnore I have updated the tests quite a bit, please review when you are free, thanks a lot. about |
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
I see, so you cannot really verify the in-memory state then, sorry for confusing, and thank you for the context.
That does not seem good and we'd better keep this listener in tests, but for now let's move on, as indeed this works when tested manually, and the json values are tested now.
Thank you a lot for bearing to this point!
|
@SomeoneToIgnore Thank you too, I do learn a lot during a whole process. And an extra wholehearted thanks to go through the structure of editor appearance with me, thus the patience to explain concepts and mindset. |
…es#49027) Mentioned in zed-industries#47258 Release Notes: - Added hotkey options and actions for toggling light and dark theme. - Add default keymap as `cmd/ctrl+k cmd/ctrl+shift+t`




Mentioned in #47258
Release Notes:
cmd/ctrl+k cmd/ctrl+shift+t