llvm-project
5375d3c7 - [lldb] Improve ansi::OutputWordWrappedLines (#181165)

Commit
1 day ago
[lldb] Improve ansi::OutputWordWrappedLines (#181165) This PR fixes a few issues including one that prevented the use of llvm::StringRef. Follow up to #180947. Some behaviour for rarely seen inputs has been defined. For example empty strings. In normal use with command descriptions we do not expect this to happen, but now it's a utility function, it's easier to reason about if we cover all possible inputs. * Empty string in now results in an empty string out. Rather than a single newline. This is less surprising, since no lines were split. * Bugs were fixed in the handling of single word inputs. If a single word cannot fit within the column limit we just print it unmodified. * Leading spaces are trimmed from input and if that results in no text, empty string is returned. Another unexpected input, but cheap to handle and makes the rest of the code a bit simpler. * llvm::StringRef is now used for the input text. This was enabled by fixing a bug in checking whether end had reached final_end. I think the previous logic caused us to read out of bounds by 1 byte sometimes. * Some buggy test output has changed but this is fine, no one is relying on that buggy behaviour. Ultimately I may wipe out all these changes later with a new implementaion, but I think it's a good approach to do this incremenetally at first.
Author
Parents
Loading