Skip to content

Conversation

@majiayu000
Copy link
Contributor

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) and ResetColor) at the beginning of repaint_buffer() function to ensure any leftover styling is cleared before the prompt is rendered.

Test Plan

  • All existing tests pass
  • Manual testing: run commands that output styled text without reset, verify prompt displays correctly

Fixes nushell/nushell#16384

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>
@majiayu000
Copy link
Contributor Author

You're right, removed. SGR 0 resets everything including colors.

Copy link
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work better for me. Thanks

Copy link
Member

@Ecorous Ecorous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@fdncred fdncred merged commit 4cce77d into nushell:main Dec 29, 2025
6 checks passed
@fdncred
Copy link
Contributor

fdncred commented Dec 29, 2025

Thanks!

@majiayu000 majiayu000 deleted the fix/ansi-reset-before-prompt branch December 29, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text has ANSI styling (no reset) before prompt is printed

4 participants