[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 01:37:01 PDT 2020


teemperor added a comment.

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?

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

>>>> I don't think the value of m_previous_autosuggestion_size should only grow (which is what this if is doing), as this way we just keep printing a longer and longer space buffer over time. Just printing enough to clear the buffer of the previous completion is enough.
>>>
>>> If I keep the number of characters of the only previous command, I think there is a problem. For example, If I type "help frame var" → "help frame info" → "help frame v", the remains are hidden. However, If I type "help frame var" → "help frame info" → "help" → "help frame v", the number of characters of "help frame var" is more than that of "help", so "help frame v[aro]" is displayed. What do you think?
>>
>> Not sure if I understand your example correctly, but as soon as you type "help frame ", you should have an autosuggestion of "help frame info" and then typing the "v" should clear the "nfo" part. The "help" autosuggestion should not be involved at all in any logic after you typed "help "?
>
> What I mean is that if I should keep the length of characters of the only previous command, following thing occurs.
>
> 1. execution "help frame var" and m_previous_autosuggestion_size = len("help frame var") = 14
> 2. execution "help frame info" and m_previous_autosuggestion_size = len("help frame info") = 15
> 3. execution "help" and m_previous_autosuggestion_size = len("help") = 4
> 4. Typing "help frame v". Then, spaces_to_print = m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 4 - 12 - 2 < 0. So, spaces are not added. (In short, "help frame v[aro]" is displayed.)
>
> (Maybe, I do not understand what you say. )

I think you got it :). My point was that `m_previous_autosuggestion_size` is updated everytime you type a character from what I can see, so you don't see the `4` from step 3. It's more like this from what I can tell:

1. same as your step 1.
2. same as your step 2.
3. same asyour step 3: execution "help" and m_previous_autosuggestion_size = len("help") = 4

3.5 [new step]: Typing "help frame ". m_previous_autosuggestion_size = len("help frame info") = 15. This is because we update the size in TypedCharacter which gets triggered for every character.

4. Typing "help frame v". Then, spaces_to_print = m_previous_autosuggestion_size - line.size() - to_add.getValue().length() = 15 - 12 - 2 = 1. (which is exactly the space needed to overwrite the 'o').



================
Comment at: lldb/source/Host/common/Editline.cpp:1009
         to_add.push_back(request.GetParsedArg().GetQuoteChar());
+      if (m_suggestion_callback && to_add.empty()) {
+        to_add.push_back(' ');
----------------
I think this can be shortened to just:
```
lang=c++
      to_add.push_back(' ');
      el_insertstr(m_editline, to_add.c_str());
      // Clear autosuggestion from line buffer if we only added a space.
      if (to_add == " ")
        return CC_REDISPLAY;
      return CC_REFRESH;
    }
```


================
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);
----------------
The `(int)` cast isn't necessary.


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

https://reviews.llvm.org/D81001



More information about the lldb-commits mailing list