Let --show-themes accept --dark and --light together - #2217
Open
VXNCXNX wants to merge 1 commit into
Open
Conversation
The help text documents using both flags with --show-themes to see both kinds, but validate_light_and_dark ran before subcommand dispatch and killed it. The (dark && light) branch in show_themes.rs was already there, just unreachable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
--show-themes --dark --lightis documented and does not work.The help text for
show_themesinsrc/cli.rssays:But:
The cause
validate_light_and_darkinsrc/options/set.rsruns before any subcommand dispatch, so it kills--show-themesalong with everything else.The intent is still in the tree:
src/subcommands/show_themes.rs:64has a|| (dark && light)branch that is currently unreachable. It was written for exactly this.The fix
Exempt
--show-themesfrom the mutual-exclusion check, which re-arms that branch. Nothing inshow_themes.rschanges.Two things I checked
opt.lightandopt.darkfeed onlytheme::get_color_mode, wherelightwins if both are set. That resolves to a valid, fully populated config, and it is only used for the outer shell: the per-theme configs inside the loop are rebuilt from--features <theme>, so the outer colour mode does not affect what is rendered.--show-syntax-themesmakes no such promise, its help text never mentions the flags, so I did not extend the fix to it.--show-syntax-themes --dark --lightstill exits fatally, the same before and after.Verification
With a HOME holding a themes gitconfig containing one dark and one light theme:
And the guard still does its job for normal use:
cargo fmt --all --check,cargo clippy -- -D warnings,cargo build --releaseandcargo test(438 passed) are all clean, plustests/test_deprecated_options.The new integration test spawns the binary with its own HOME, because
GitConfig::try_createreturnsNoneundercfg(test), so a unit test finds no themes at all. Revertingset.rswith the test kept makes it fail.One note unrelated to this change:
cargo clippy --all-targets -- -D warningsreports 4needless_borrowerrors insrc/utils/process.rs. I confirmed those on a clean tree. CI's gate iscargo clippy -- -D warningswithout--all-targets, which passes.There is no issue for this one, I noticed it while reading the help text.