Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autocompletion leading to duplicated symbols and tokens #527

Merged
merged 4 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions lib/SerenataClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,17 @@ class SerenataClient extends AutoLanguageClient
});
}

onDidConvertAutocomplete(completionItem, suggestion/*, request*/) {
onDidConvertAutocomplete(completionItem, suggestion, request) {
const textEdit = completionItem.textEdit;

// TODO: Workaround for https://github.com/atom-community/atom-languageclient/pull/207
if (textEdit && textEdit.newText.substring(0, 2) === '\\$') {
suggestion.customReplacmentPrefix = request.editor.getTextInBufferRange([
[textEdit.range.start.line, textEdit.range.start.character],
request.bufferPosition
]);
}

suggestion.className = 'php-ide-serenata-autocompletion-suggestion';

if (completionItem.deprecated) {
Expand Down Expand Up @@ -461,26 +471,6 @@ class SerenataClient extends AutoLanguageClient
suggestion.rightLabel = detailParts.join(' — ');
}

onDidInsertSuggestion({editor/*, triggerPosition*/, suggestion}) {
const additionalTextEdits = suggestion.completionItem.additionalTextEdits;

if (!additionalTextEdits || additionalTextEdits.length === 0) {
return;
}

return editor.transact(() => {
return additionalTextEdits.map((additionalTextEdit) => {
editor.setTextInBufferRange(
[
[additionalTextEdit.range.start.line, additionalTextEdit.range.start.character],
[additionalTextEdit.range.end.line, additionalTextEdit.range.end.character]
],
additionalTextEdit.newText
);
});
});
}

onOpenTextDocument(parameters) {
const {Convert} = require('atom-languageclient');

Expand Down
Loading