From a05fc52fc8bf6978c21f83317bf08a296d96c2de Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sat, 17 Jul 2021 22:35:30 +0200 Subject: [PATCH] Ignore second escape inside an escape code --- src/builtin_string.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index dec94c479..8aaeabf61 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -221,8 +221,13 @@ static size_t width_without_escapes(wcstring ins) { auto w = fish_wcwidth(c); if (w > 0) width -= w; } + // Move us forward behind the escape code, + // it might include a second escape! + // E.g. SGR0 ("reset") is \e\(B\e\[m in xterm. + pos += *len - 1; + } else { + pos++; } - pos++; } return width; }