Repository: llvm/llvm-project
File: lldb/include/lldb/Utility/AnsiTerminal.h (C/C++)

Code before:
          trimmed_width !=
              llvm::sys::unicode::ColumnWidthErrors::ErrorInvalidUTF8 &&
          // If the trimmed string fits, take it.
          result_visibile_length + static_cast<size_t>(trimmed_width) <=
              visible_length) {
        result.append(trimmed);
        result_visibile_length += static_cast<size_t>(trimmed_width);
        break;
      }
      trimmed = trimmed.drop_back();
    }
  }

  // Pad the string.
  if (result_visibile_length < visible_length)
    result.append(visible_length - result_visibile_length, padding);

  return result;
}

// Output text that may contain ANSI codes, word wrapped (wrapped at whitespace)
// to the given stream. The indent level of the stream is counted towards the
// output line length.
inline void OutputWordWrappedLines(Stream &strm, llvm::StringRef text,
                                   uint32_t output_max_columns,
                                   bool use_color) {
  // We will indent using the stream, so leading whitespace is not significant.
  text = text.ltrim();
  if (text.empty())
    return;

  // 1 column border on the right side.
  const uint32_t max_text_width =
      output_max_columns - strm.GetIndentLevel() - 1;
  bool first_line = true;

  while (!text.empty()) {
    std::string split = TrimAtWordBoundary(text, max_text_width);
    if (!first_line)
      strm.EOL();
    first_line = false;

    if (use_color) {
      // If we are allowed to use colour (aka ANSI codes), we can indent using
      // ANSI cursor movement. This means that if an ANSI formatted range of
      // text is split across two lines, the indentation is not also formatted.
      // Which it would be if we just emitted spaces.
      const std::string ansi_indent =
          ANSI_CSI_CUF(std::to_string(strm.GetIndentLevel()));
      strm << ansi_indent << split;
    } else

Review comment (suggestion):
This name has always been half correct, but our setting and most users think of it this way. So I was tempted to call this use_ansi but I thought that might be even more confusing.

In some way, here it's "use even more ansi". Since if color was disabled, the input string has all ansi removed.

Code after:
          trimmed_width !=
              llvm::sys::unicode::ColumnWidthErrors::ErrorInvalidUTF8 &&
          // If the trimmed string fits, take it.
          result_visibile_length + static_cast<size_t>(trimmed_width) <=
              visible_length) {
        result.append(trimmed);
        result_visibile_length += static_cast<size_t>(trimmed_width);
        break;
      }
      trimmed = trimmed.drop_back();
    }
  }

  // Pad the string.
  if (result_visibile_length < visible_length)
    result.append(visible_length - result_visibile_length, padding);

  return result;
}

// Output text that may contain ANSI codes, word wrapped (wrapped at whitespace)
// to the given stream. The indent level of the stream is counted towards the
// output line length.
inline void OutputWordWrappedLines(Stream &strm, llvm::StringRef text,
                                   uint32_t output_max_columns,
                                   bool use_color) {
  // We will indent using the stream, so leading whitespace is not significant.
  text = text.ltrim();
  if (text.empty())
    return;

  // 1 column border on the right side.
  const uint32_t max_text_width =
      output_max_columns - strm.GetIndentLevel() - 1;
  bool first_line = true;
  const std::string ansi_indent =
      ANSI_CSI_CUF(std::to_string(strm.GetIndentLevel()));

  while (!text.empty()) {
    std::string split = TrimAtWordBoundary(text, max_text_width);
    if (!first_line)
      strm.EOL();
    first_line = false;

    if (use_color) {
      // If we are allowed to use colour (aka ANSI codes), we can indent using
      // ANSI cursor movement. This means that if an ANSI formatted range of
      // text is split across two lines, the indentation is not also formatted.
      // Which it would be if we just emitted spaces.
      strm << ansi_indent << split;
    } else {