From fa7c8d59a2c37f154e3baf8c11f48c01473e765a Mon Sep 17 00:00:00 2001 From: Volodya Date: Wed, 1 May 2024 11:47:59 +0000 Subject: [PATCH] without transfer at max column width --- .../Formats/Impl/PrettyBlockOutputFormat.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp index 7338ae18310..9f453be8827 100644 --- a/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp +++ b/src/Processors/Formats/Impl/PrettyBlockOutputFormat.cpp @@ -466,6 +466,7 @@ void PrettyBlockOutputFormat::writeValueWithPadding( serialized_value += ellipsis; value_width = format_settings.pretty.max_value_width; + has_break_line = false; } else if (!has_break_line) serialized_value += ' '; @@ -492,7 +493,7 @@ void PrettyBlockOutputFormat::writeValueWithPadding( write_padding(); } - if (has_break_line && value_width != format_settings.pretty.max_value_width) + if (has_break_line) writeString("…", out); } @@ -535,6 +536,25 @@ void PrettyBlockOutputFormat::writeTransferredRow(const Widths & max_widths, con has_break_line = true; } + if (cur_width > format_settings.pretty.max_value_width) + { + value.resize(UTF8::computeBytesBeforeWidth( + reinterpret_cast(value.data()), value.size(), 0, 1 + format_settings.pretty.max_value_width)); + + const char * ellipsis = format_settings.pretty.charset == FormatSettings::Pretty::Charset::UTF8 ? "⋯" : "~"; + if (color) + { + value += "\033[31;1m"; + value += ellipsis; + value += "\033[0m"; + } + else + value += ellipsis; + + cur_width = format_settings.pretty.max_value_width; + has_break_line = false; + } + if (!value.empty()) writeString("…", out); else @@ -552,7 +572,7 @@ void PrettyBlockOutputFormat::writeTransferredRow(const Widths & max_widths, con if (has_break_line) writeString("…", out); - else + else if (cur_width != format_settings.pretty.max_value_width) writeChar(' ', out); }