From a0a9e48f85f84f80d850da6f349cc754739e62d6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Aug 2025 15:19:31 -0400 Subject: [PATCH] StdIo: Fix Terminal abstraction to avoid unnecessary VT100 escape sequences Fix commit 329d755dbd (StdIo: Add a Terminal abstraction to print color text, 2025-05-06, v4.1.0-rc1~151^2~3) to avoid printing a VT100 escape sequence for normal text if we did not print any sequence initially. We already use this approach for Windows Console text attributes. Issue: #26924 --- Source/cmStdIoTerminal.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/cmStdIoTerminal.cxx b/Source/cmStdIoTerminal.cxx index 5baff5e38b..428f7c7fae 100644 --- a/Source/cmStdIoTerminal.cxx +++ b/Source/cmStdIoTerminal.cxx @@ -141,9 +141,13 @@ void Print(OStream& os, TermAttrSet const& attrs, f(os.IOS()); break; case TermKind::VT100: - SetVT100Attrs(os.IOS(), attrs); - f(os.IOS()); - SetVT100Attrs(os.IOS(), TermAttr::Normal); + if (!attrs.empty()) { + SetVT100Attrs(os.IOS(), attrs); + f(os.IOS()); + SetVT100Attrs(os.IOS(), TermAttr::Normal); + } else { + f(os.IOS()); + } break; #ifdef _WIN32 case TermKind::Console: {