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

Handle replaceStart/replaceEnd in completion proposal #526

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,16 @@ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
data.put(CompletionResolveHandler.DATA_FIELD_REQUEST_ID, String.valueOf(response.getId()));
data.put(CompletionResolveHandler.DATA_FIELD_PROPOSAL_ID, String.valueOf(index));
$.setData(data);

this.descriptionProvider.updateDescription(proposal, $);
// Use fully qualified name as needed.
$.setInsertText(String.valueOf(proposal.getCompletion()));
String insertText = String.valueOf(proposal.getCompletion());
int prefix = proposal.getReplaceEnd() - proposal.getReplaceStart();
if (prefix > 0) {
$.setInsertText(insertText.substring(prefix));
} else {
$.setInsertText(insertText);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't work for VS Code. Typing Sys to trigger completion, select System and it becomes tem.

adjustCompleteItem($);
$.setSortText(SortTextHelper.computeSortText(proposal));
return $;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<unit id="org.eclipse.jdt.source.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.xtext.sdk.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/releases/2023-12/202311171000/"/>
<repository location="https://download.eclipse.org/releases/2023-12/202312061001/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.jboss.tools.maven.apt.core" version="0.0.0"/>
Expand All @@ -32,4 +32,4 @@
<unit id="org.eclipse.lsp4j.sdk.feature.group" version="0.0.0"/>
</location>
</locations>
</target>
</target>
Loading