atom-languageclient icon indicating copy to clipboard operation
atom-languageclient copied to clipboard

Autocompletion for C++ preprocessor directives doesn't delete existing text properly

Open rianneogi opened this issue 6 years ago • 4 comments

Hi, I'm using ide-cquery package for C++ autocompletion.

When I type #include <stdi, the completion returns #include <stdio.h>. However, if I press enter to trigger the completion the resulting string will be #include <#include <stdio.h>. It doesn't seem to delete the text before the <.

Another example: Type #def, autocomplete will suggest #define but ##define (double hashtag) is inserted upon pressing enter, it doesn't delete the first #.

rianneogi avatar May 25 '18 07:05 rianneogi

Seeing what appears to be the same issue with Hack, when completing variable names:

  1. Use a variable $foo
  2. Type $f to trigger autocomplete
  3. Gets completed to $$foo instead of $foo

If not setting useTextEditAutocomplete in initializationOptions, this is inserted text, and appears to be buggy in Hack - it does not work correctly in vscode or vim. However, if that option is set, TextEdits are sent, which work correctly in vscode and vim, but not atom.

fredemmott avatar Jul 13 '18 15:07 fredemmott

I have the same problem here using ide-cquery for autocompletion. Does anyone have a solution?

YusufMohammedUH avatar Mar 19 '20 11:03 YusufMohammedUH

Seems to be related to the fact that those completions have an empty insertText and that their label is used instead.

The following modification seems to do the trick, but not sure if this is the best thing to do:

--- a/lib/adapters/autocomplete-adapter.ts
+++ b/lib/adapters/autocomplete-adapter.ts
@@ -393,7 +393,7 @@ export default class AutocompleteAdapter {
     item: CompletionItem,
     suggestion: TextSuggestion,
   ) {
-    suggestion.text = item.insertText || item.label;
+    suggestion.text = item.insertText || "";
     suggestion.filterText = item.filterText || item.label;
     suggestion.displayText = item.label;
     suggestion.type = AutocompleteAdapter.completionKindToSuggestionType(item.kind);

fargies avatar Apr 16 '20 21:04 fargies

Development of atom-languageclient has officially moved to https://github.com/atom-ide-community/atom-languageclient 🎉

If this is still an issue please consider opening an issue on that repo.

UziTech avatar Oct 19 '20 19:10 UziTech