From c24166996b88303e5cb4aaa5a6b1ab57d42f3b2e Mon Sep 17 00:00:00 2001 From: majiayu000 <1835304752@qq.com> Date: Mon, 29 Dec 2025 15:49:55 +0800 Subject: [PATCH 1/2] 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 <1835304752@qq.com> --- src/painting/painter.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/painting/painter.rs b/src/painting/painter.rs index 9426a6d7..d0f2d428 100644 --- a/src/painting/painter.rs +++ b/src/painting/painter.rs @@ -208,6 +208,12 @@ impl Painter { use_ansi_coloring: bool, cursor_config: &Option, ) -> Result<()> { + // Reset any ANSI styling that may have been left by external commands + // This ensures the prompt is not affected by previous output styling + self.stdout + .queue(SetAttribute(Attribute::Reset))? + .queue(ResetColor)?; + self.stdout.queue(cursor::Hide)?; let screen_width = self.screen_width(); From df2ac6952a68d0667fb0982721cf7936e6aa9271 Mon Sep 17 00:00:00 2001 From: majiayu000 <1835304752@qq.com> Date: Mon, 29 Dec 2025 19:52:56 +0800 Subject: [PATCH 2/2] refactor: remove redundant ResetColor since SGR 0 resets all --- src/painting/painter.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/painting/painter.rs b/src/painting/painter.rs index d0f2d428..b27f036a 100644 --- a/src/painting/painter.rs +++ b/src/painting/painter.rs @@ -210,9 +210,8 @@ impl Painter { ) -> Result<()> { // Reset any ANSI styling that may have been left by external commands // This ensures the prompt is not affected by previous output styling - self.stdout - .queue(SetAttribute(Attribute::Reset))? - .queue(ResetColor)?; + // Note: Attribute::Reset (SGR 0) resets all attributes including colors + self.stdout.queue(SetAttribute(Attribute::Reset))?; self.stdout.queue(cursor::Hide)?;