Repository navigation
fix(prompt): don't tint a supplied prompt with the default colors - #18686
kronberger-droid merged 2 commits into
Conversation
| @@ -1,3 +1,4 @@ | |||
| use crossterm::style::Color; | |||
There was a problem hiding this comment.
Is there a reason we're not using nu_ansi_term here? All coloring in nushell and reedline should be nu_ansi_term iirc.
|
Wow the prompt indicator situation is a mess. It seems it was made pretty early and was never updated. Is there any reason why these would be plain env variables and not handled by the config? Without changing this we can only use the default color easily for everything but the prompt indicator, which would be white, since it will be handled as customized. Should I try to clean this up in here, or in a follow-up? |
I'm not sure really. They've just always been that way.
Probably separate but before we land this one.
We should probably talk about it, maybe in our meeting today. It'll be a breaking change though. Seems like it should be part of the config.nu to me too. |
|
Sure lets talk tonight. |
|
Also worth nothing, the entire config is in |
1cc2a5d to
46226e4
Compare
NushellPrompt forced nushell's default foregrounds on every prompt piece, so an unstyled custom prompt, like starship with `style = ""`, inherited them instead of the terminal foreground. The left and right prompt now return `Color::Default` when the user supplies them, and keep the built-in color only for the fallbacks. The indicators stay tinted. They are nushell's own rather than output of the user's prompt generator, since reedline picks one from the current edit mode, which `$env.PROMPT_COMMAND` cannot see. Styling one means putting the escapes in the indicator value. Their colors are stated explicitly rather than inherited from the `Prompt` trait defaults, so nushell's appearance does not follow reedline's. The constants come from reedline's `DEFAULT_*` statics, since the prompt colors moved to `nu_ansi_term::Color` there in 83c17a2. Fixes nushell#16384
46226e4 to
15742cb
Compare
|
I don't remember what we decided here? Or maybe this PR is dependent on the prompt indicators PR? |
|
Yeah exactly. We decided to first land the prompt PR. And then land this one, with default colors, with no custom prompt and with custom prompt we just do a color reset. |
…olor-reset `NushellPrompt` no longer owns its segments since nushell#19236, thus the colors ask the shared `PromptState` whether a side was supplied.
Description
reedline prints a foreground color in front of the left and the right prompt, and
NushellPromptnever overrode it.Thus every unstyled piece of a custom prompt, like a starship module with
style = "none", came out light green or purple instead of in the terminal's own foreground.NushellPromptnow answersColor::Defaultfor a side that was supplied, and keeps reedline's colors for a side that falls back to the built-in prompt.The two sides are judged separately.
The indicators keep their default colors.
They are nushell's own rather than the prompt generator's, and styling one means putting the escapes into the indicator value.
User-facing changes (Release notes)
Fixed unstyled text in a custom prompt being tinted light green (left) or purple (right).
It now uses the terminal's default foreground, as in other shells.
A prompt that sets its own colors looks the same as before.
Additional notes
fixes #16384
Based on
main, since thePromptStaterewrite it needed is already there.It conflicts with #18734 in one hunk, both append tests to
crates/nu-cli/src/prompt.rs, so whichever lands second needs that merge.