Skip to content

Commit

Permalink
match filterText with textEdit
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Zhang <[email protected]>
  • Loading branch information
Eskibear authored and fbricon committed Feb 28, 2020
1 parent 0585be7 commit 59b223a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ public CompletionItem toCompletionItem(CompletionProposal proposal, int index) {
}
}
proposalProvider.updateReplacement(proposal, $, '\0');
// Make sure `filterText` matches `textEdit`
// See https://github.com/eclipse/eclipse.jdt.ls/issues/1348
if (proposal.getKind() == CompletionProposal.TYPE_REF && $.getTextEdit() != null && $.getTextEdit().getRange() != null && $.getTextEdit().getNewText() != null) {
$.setFilterText($.getTextEdit().getNewText());
}
return $;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ public void testCompletion_object() throws Exception{
assertTrue(isNotBlank(item.getInsertText()));
assertNotNull(item.getFilterText());
assertFalse(item.getFilterText().contains(" "));
assertTrue(item.getLabel().startsWith(item.getFilterText()));
assertTrue(item.getLabel().startsWith(item.getInsertText()));
assertTrue(item.getFilterText().startsWith("Objec"));
//Check contains data used for completionItem resolution
@SuppressWarnings("unchecked")
Map<String,String> data = (Map<String, String>) item.getData();
Expand Down Expand Up @@ -790,6 +791,7 @@ public void testCompletion_import_type() throws JavaModelException{
assertEquals("Map", item.getInsertText());
assertNotNull(item.getTextEdit());
assertTextEdit(3, 3, 15, "java.util.Map", item.getTextEdit());
assertTrue(item.getFilterText().startsWith("java.util.Ma"));
//Not checking the range end character
}

Expand Down

0 comments on commit 59b223a

Please sign in to comment.