From 897769a90d768f26afb359fab015e4e2b64aebf3 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Wed, 9 Feb 2022 21:58:41 +0100 Subject: [PATCH] Fixed: Logic of Fx::uncolor() --- src/btop_tools.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index f48584e..23ea8ae 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -148,12 +148,12 @@ namespace Fx { if (start_pos == string::npos) break; offset = start_pos + 1; - for (end_pos = out.find('m', offset); end_pos != string::npos and not isdigit(out.at(end_pos - 1)); end_pos = out.find('m', end_pos + 1)); + end_pos = out.find('m', offset); if (end_pos == string::npos) break; - else if (auto next_pos = out.find('\x1b', offset); end_pos >= next_pos) { - continue; - } + else if (auto next_pos = out.find('\x1b', offset); not isdigit(out[end_pos - 1]) or end_pos > next_pos) + continue; + out.erase(start_pos, (end_pos - start_pos)+1); offset = 0; }