[Lldb-commits] [PATCH] D81001: [lldb] Display autosuggestion part in gray if there is one possible suggestion

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 6 04:30:49 PDT 2020


teemperor added a comment.

In D81001#2199205 <https://reviews.llvm.org/D81001#2199205>, @gedatsu217 wrote:

>> So the way the issue with the single space is now solved is by doing CC_REDISPLAY when we're only adding the single space? Isn't that also deleting the whole autosuggestion?
>
> Yes. CC_REDISPLAY can delete all the gray characters left.

So, if I would type "b" and then press tab, the autosuggestion would briefly disappear until I type the next character?



================
Comment at: lldb/source/Host/common/Editline.cpp:1081
+    if (spaces_to_print > 0) {
+      std::string spaces = std::string((int)spaces_to_print, ' ');
+      fputs(spaces.c_str(), m_output_file);
----------------
gedatsu217 wrote:
> teemperor wrote:
> > The `(int)` cast isn't necessary.
> I found that lldb crashed. Sorry, I should have checked more when I uploaded this.
> 
> I use spaces_to_print as size_t, but this sometimes becomes less than zero. So, I have to use this as int.
> 
> 
Yeah I see that spaces_to_print can overflow. How about this code instead that avoids all the casting and overflowing and so on:

```
lang=c++
size_t new_autosuggestion_size = line.size() + to_add->length();
// If the previous command line + autosuggestion was longer than the
// current autosuggestion, make sure that the autosuggestion is overwriting
// the old output by enough adding trailing spaces.
if (new_autosuggestion_size < m_previous_autosuggestion_size) {
  size_t spaces_to_print = m_previous_autosuggestion_size - new_autosuggestion_size;
  std::string spaces = std::string(spaces_to_print, ' ');
  fputs(spaces.c_str(), m_output_file);
}
m_previous_autosuggestion_size = new_autosuggestion_size;
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81001/new/

https://reviews.llvm.org/D81001



More information about the lldb-commits mailing list