-
Notifications
You must be signed in to change notification settings - Fork 55
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
Completion items are not sorted when extra text typed after completion invocation #842
Comments
One possible workaround can probably be to use |
Isn't it the root issue? |
While Not being able to reorder is an usability problem, so it would be nice if someone would have time to fix it. Maybe it requires a platform change? |
@mickaelistria
@Override
public boolean isValidFor(IDocument document, int offset) {
return (!isIncomplete || offset == this.initialOffset) && validate(document, offset, null);
} but looking at the code in if (proposal instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 p= (ICompletionProposalExtension2) proposal;
try {
if (p.validate(document, offset, event))
filtered.add(proposal);
} catch (RuntimeException e) {
// Make sure that poorly behaved completion proposers do not break filtering.
}
} else if (proposal instanceof ICompletionProposalExtension) {
ICompletionProposalExtension p= (ICompletionProposalExtension) proposal;
try {
if (p.isValidFor(document, offset))
filtered.add(proposal);
} catch (RuntimeException e) {
// Make sure that poorly behaved completion proposers do not break filtering.
}
} else {
// restore original behavior
fIsFilteredSubset= false;
fInvocationOffset= offset;
fContentAssistant.fireSessionRestartEvent();
fComputedProposals= computeProposals(fInvocationOffset);
return fComputedProposals;
} Thus it never gets to I put the following code in @Override
public boolean validate(IDocument document, int offset, DocumentEvent event) {
if (item.getLabel() == null || item.getLabel().isEmpty()) {
return false;
}
if (offset < this.bestOffset) {
return false;
}
try {
String documentFilter = getDocumentFilter(offset);
if (!documentFilter.isEmpty()) {
return /* CHANGE START*/!(isIncomplete && currentOffset != initialOffset) && /* CHANGE END */ CompletionProposalTools.isSubstringFoundOrderedInString(documentFilter, getFilterString());
} else if (item.getTextEdit() != null) {
return offset == LSPEclipseUtils.toOffset(getTextEditRange().getStart(), document);
}
} catch (BadLocationException e) {
LanguageServerPlugin.logError(e);
}
return true;
} |
@BoykoAlex can we close this issue? |
Hmm... I think so, but let me check this out first and get back to you |
Looks like the merged PR is only to address the support for |
Does anyone have a pointer here where the |
The
LSContentAssistProcessor
sorts completions based on the rank when completions are first computed. If extra chars are typed after the initial CA invocation then the list of proposals is filtered (as invalid proposals are filtered out) but never sorted again based on the document filter text. The generic editorContentAssistant
isnull
thus nothing is sorted after the initial invocation. The result is irrelevant completion proposals ends up at the top of the list.It'd be great if somehow we could set the sorter on the
ContentAssistant
... I couldn't find a way unfortunately and ended up using reflection just to test the hypothesis.After writing the code below in lsp4e i was able to achieve the desired effect:
I'd be more than happy to provide a patch if someone points in the right direction to implement this elegantly :-)
The text was updated successfully, but these errors were encountered: