================
@@ -927,12 +927,92 @@ unsigned char Editline::BufferEndCommand(int ch) {
static void
PrintCompletion(FILE *output_file,
llvm::ArrayRef<CompletionResult::Completion> results,
- size_t max_len) {
+ size_t max_completion_length, size_t max_lenght) {
+
+ constexpr size_t ellipsis_length = 3;
+ constexpr size_t tab_legnth = 8;
+ constexpr size_t separator_length = 4;
+ const size_t description_col =
+ std::min(max_completion_length + tab_legnth, max_lenght);
+
for (const CompletionResult::Completion &c : results) {
- fprintf(output_file, "\t%-*s", (int)max_len, c.GetCompletion().c_str());
- if (!c.GetDescription().empty())
- fprintf(output_file, " -- %s", c.GetDescription().c_str());
- fprintf(output_file, "\n");
+ // Print the leading tab-sized padding.
+ fprintf(output_file, " ");
+ size_t cursor = tab_legnth;
+
+ if (!c.GetCompletion().empty()) {
+ const size_t completion_length = c.GetCompletion().size();
+ if (cursor + completion_length < max_lenght) {
+ fprintf(output_file, "%s", c.GetCompletion().c_str());
+ cursor = cursor + completion_length;
----------------
labath wrote:
```suggestion
fprintf(output_file, "%-*s", max_length, c.GetCompletion().c_str());
```
And then you don't need the cursor and the padding code below?
(The difference is that this prints the padding even if description is empty,
but I don't think that needs to bother us)
https://github.com/llvm/llvm-project/pull/116456
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits