Skip to content

Commit 4cce77d

Browse files
authored
fix: reset ANSI styling before printing prompt (#992)
* fix: reset ANSI styling before printing prompt 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 <[email protected]> * refactor: remove redundant ResetColor since SGR 0 resets all --------- Signed-off-by: majiayu000 <[email protected]>
1 parent b81c351 commit 4cce77d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/painting/painter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ impl Painter {
208208
use_ansi_coloring: bool,
209209
cursor_config: &Option<CursorConfig>,
210210
) -> Result<()> {
211+
// Reset any ANSI styling that may have been left by external commands
212+
// This ensures the prompt is not affected by previous output styling
213+
// Note: Attribute::Reset (SGR 0) resets all attributes including colors
214+
self.stdout.queue(SetAttribute(Attribute::Reset))?;
215+
211216
self.stdout.queue(cursor::Hide)?;
212217

213218
let screen_width = self.screen_width();

0 commit comments

Comments
 (0)