atom-languageclient
atom-languageclient copied to clipboard
Autocompletion for C++ preprocessor directives doesn't delete existing text properly
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 #
.
Seeing what appears to be the same issue with Hack, when completing variable names:
- Use a variable
$foo
- Type
$f
to trigger autocomplete - 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.
I have the same problem here using ide-cquery for autocompletion. Does anyone have a solution?
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);
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.