# HG changeset patch # User František Kučera # Date 1575063297 -3600 # Node ID f03e1f9cfcb6eae2f1def43fd07a6012bc7e257d # Parent 32824e833b89b6765d671cc41a4261cf961fc45c compute correct width for whitespace characters that will be replaced diff -r 32824e833b89 -r f03e1f9cfcb6 src/TabularPrefetchingHandler.h --- a/src/TabularPrefetchingHandler.h Sun Nov 17 17:51:13 2019 +0100 +++ b/src/TabularPrefetchingHandler.h Fri Nov 29 22:34:57 2019 +0100 @@ -80,6 +80,7 @@ result << convertor.from_bytes(color); for (auto & ch : value) { + // see computeWidth below switch (ch) { case L'\n': result << colorizeReplacement(L"↲", color); break; @@ -104,7 +105,19 @@ */ integer_t computeWidth(const string_t& stringValue) { integer_t width = 0; - for (wchar_t ch : stringValue) width += std::max(0, wcwidth(ch)); + for (wchar_t ch : stringValue) { + // see formatValue() above + switch (ch) { + case L'\n': + case L'\r': + case L'\t': + case L' ': + width += 1; + break; + default: + width += std::max(0, wcwidth(ch)); + } + } return width; }