================
@@ -138,19 +147,13 @@ CompletionsRequestHandler::Run(const CompletionsArguments 
&args) const {
       const StringRef match = matches.GetStringAtIndex(i);
       const StringRef description = descriptions.GetStringAtIndex(i);
 
-      StringRef match_ref = match;
-      for (const StringRef commit_point : {".", "->"}) {
-        if (const size_t pos = match_ref.rfind(commit_point);
-            pos != StringRef::npos) {
-          match_ref = match_ref.substr(pos + commit_point.size());
-        }
-      }
-
       CompletionItem item;
-      item.text = match_ref;
       item.label = match;
       if (!description.empty())
         item.detail = description;
+      // lldb returned completions includes the partial typed token
+      // overwrite it.
+      item.length = partial_token_len;
 
       targets.emplace_back(std::move(item));
     }
----------------
da-viper wrote:

```py
We want to complete "ghi"

## Space at the cursor position
"abc def "
        ^  
rfind(' ') = 7 , tok_len = linesize - (7 + 1) = 8 - 8 = 0
# move back 0 position and becomes
"abc def " 
            ^
# completes
"abc def ghi"
           ^

## No space at the cursor position
"abc def" # no space here
       ^
rfind(' ') = 3 , tok_len = linesize - (3 + 1) = 7 - 4 = 3
# move back 3 positions and becomes
"abc def"
    ^
# completes
"abc ghidef"
       ^

## No space in the input
"abc"
   ^
rfind(' ') = npos , tok_len = linesize = 3
# move back 3 positions and becomes
"abc"
^
# completes
"ghiabc"
   ^
```

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

Reply via email to