atom / atom-languageclient

Language Server Protocol support for Atom (the basis of Atom-IDE)
https://ide.atom.io/
MIT License
388 stars 78 forks source link

replacementPrefix generated by textEdit for autocompletion suggestions is overruled #266

Closed Gert-dev closed 3 years ago

Gert-dev commented 5 years ago

The Serenata server generates autocompletion suggestions that carry a textEdit property that can replace characters, for example:

<?php

/**
 * @inh
 */

In this docblock, with the cursor after the @inh text, a suggestion with text @inheritDoc is generated, which includes a textEdit that includes the range of the existing @inh text to ensure it is replaced in its entirety, along with the @ sign.

Currently, this @ sign is not replaced and the result of selecting the completion is:

<?php

/**
 * @@inheritDoc
 */

I did some digging and it turns out that the AutocompleteAdapter first properly resolves the textEdit to the replacementPrefix of value @. However, afterwards, that (correct) replacementPrefix is then trampled and overwritten by this code in AutocompleteAdapter::getSuggestions:

// As the user types more characters to refine filter we must replace those characters on acceptance
const replacementPrefix = (triggerChar !== '' && triggerOnly) ? '' : request.prefix;
for (const suggestion of suggestions) {
   suggestion.replacementPrefix = replacementPrefix;
}

This resets the replacementPrefix of @ to an empty value and seems to be the cause of the double @ symbol being inserted.

Aerijo commented 5 years ago

@Gert-dev This may be fixed on master, could you confirm?

Gert-dev commented 5 years ago

@Aerijo I can and it seems to be fixed on latest master, presumably by 3f44ceb9b8b8174fa115e5e32c14e773471d5c34.

Thanks! Feel free to close this ticket. I'll keep a lookout for a new stable release to target that contains it.

UziTech commented 3 years ago

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.