fix: reset ANSI styling before printing prompt#992
Merged
Conversation
Reset any ANSI styling that may have been left by external commands before printing the prompt. This ensures the prompt is not affected by previous output styling that was not properly reset. Fixes nushell/nushell#16384 Signed-off-by: majiayu000 <1835304752@qq.com>
ysthakur
reviewed
Dec 29, 2025
Contributor
Author
|
You're right, removed. SGR 0 resets everything including colors. |
fdncred
approved these changes
Dec 29, 2025
Contributor
fdncred
left a comment
There was a problem hiding this comment.
Seems to work better for me. Thanks
Contributor
|
Thanks! |
iniw
added a commit
to iniw/reedline
that referenced
this pull request
Apr 8, 2026
pr nushell#992 reset stale sgr state before each repaint, which fixed prompt color bleed from previous command output. it did not fix the starship case reported in starship#6560 and nushell#16384 because reedline still applied its own default prompt colors immediately before printing the prompt. that meant a prompt implementation that returned ansi text without overriding `get_prompt_color()` still inherited reedline's defaults. for starship, `style = "none"` emits no color sequence at all, so the first visible character inherited reedline's green prompt color instead of the terminal's foreground color. change the default prompt, multiline, indicator, and right-prompt colors to the terminal defaults. prompts that want explicit colors can still override the color methods, but unstyled prompts now stay unstyled and no longer need an extra reset sequence to avoid the green first character.
iniw
added a commit
to iniw/reedline
that referenced
this pull request
Apr 8, 2026
pr nushell#992 reset stale sgr state before each repaint, which fixed prompt color bleed from previous command output. it did not fix the starship case reported in starship#6560 and nushell#16384 because reedline still applied its own default prompt colors immediately before printing the prompt. that meant a prompt implementation that returned ansi text without overriding `get_prompt_color()` still inherited reedline's defaults. for starship, `style = "none"` emits no color sequence at all, so the first visible character inherited reedline's green prompt color instead of the terminal's foreground color. this patch changes the default prompt, multiline, indicator, and right-prompt colors to the terminal defaults. prompts that want explicit colors can still override the color methods, but unstyled prompts now stay unstyled and no longer need an extra reset sequence to avoid the green first character.
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.
Summary
Reset any ANSI styling that may have been left by external commands before printing the prompt. This ensures the prompt is not affected by previous output styling that was not properly reset.
Problem
When external commands output text with ANSI styling but don't include a reset sequence, the styling continues to affect the prompt display. This was reported in nushell/nushell#16384.
Solution
Added ANSI reset (
SetAttribute(Attribute::Reset)andResetColor) at the beginning ofrepaint_buffer()function to ensure any leftover styling is cleared before the prompt is rendered.Test Plan
Fixes nushell/nushell#16384