From 4a2b30c4f264cfc2cc911fdf6ea8f12e96987167 Mon Sep 17 00:00:00 2001 From: Stephan Boyer Date: Sat, 19 Sep 2026 00:21:09 +0800 Subject: [PATCH] Handle empty code strings --- src/format.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/format.rs b/src/format.rs index 2c3d7cf8..c0f37d02 100644 --- a/src/format.rs +++ b/src/format.rs @@ -9,9 +9,9 @@ pub trait CodeStr { impl CodeStr for str { fn code_str(&self) -> ColoredString { - // If colored output is enabled, format the text in magenta. Otherwise, surround it in - // backticks. - if SHOULD_COLORIZE.should_colorize() { + // If colored output is enabled, format nonempty text in magenta. Otherwise, surround it in + // backticks so even an empty string remains visible. + if !self.is_empty() && SHOULD_COLORIZE.should_colorize() { self.magenta() } else { ColoredString::from(&format!("`{self}`") as &Self)