================
@@ -278,50 +277,48 @@ void Options::OutputFormattedUsageText(Stream &strm,
   const size_t visible_length = ansi::ColumnWidth(actual_text);
 
   // Will it all fit on one line?
-
   if (static_cast<uint32_t>(visible_length + strm.GetIndentLevel()) <
       output_max_columns) {
     // Output it as a single line.
-    strm.Indent(ansi::FormatAnsiTerminalCodes(actual_text, use_color));
+    strm.Indent(actual_text);
     strm.EOL();
-  } else {
-    // We need to break it up into multiple lines.
-
-    int text_width = output_max_columns - strm.GetIndentLevel() - 1;
-    int start = 0;
-    int end = start;
-    int final_end = visible_length;
-    int sub_len;
-
-    while (end < final_end) {
-      // Don't start the 'text' on a space, since we're already outputting the
-      // indentation.
-      while ((start < final_end) && (actual_text[start] == ' '))
-        start++;
-
-      end = start + text_width;
-      if (end > final_end)
-        end = final_end;
-      else {
-        // If we're not at the end of the text, make sure we break the line on
-        // white space.
-        while (end > start && actual_text[end] != ' ' &&
-               actual_text[end] != '\t' && actual_text[end] != '\n')
-          end--;
-      }
+    return;
+  }
 
-      sub_len = end - start;
-      if (start != 0)
-        strm.EOL();
-      strm.Indent();
-      assert(start < final_end);
-      assert(start + sub_len <= final_end);
-      strm.PutCString(ansi::FormatAnsiTerminalCodes(
-          llvm::StringRef(actual_text.c_str() + start, sub_len), use_color));
-      start = end + 1;
+  // We need to break it up into multiple lines.
----------------
JDevlieghere wrote:

```suggestion
  // We need to break it up into multiple lines. We can do this with the 
formatted text because we only break a line on a whitespace, avoiding the risk 
of breaking in the middle of an escape code or Unicode character.
```
Not sure if this is worth a comment, but when I saw that `actual_text` was 
already formatted, I was worried that it was going to be tricky to do this 
right until I convinced myself that it's not because of the whitespace 
constraint. 

https://github.com/llvm/llvm-project/pull/178208
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to