Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,21 @@ public void testIncompleteIndication() throws CoreException {
assertEquals("FirstClass", proposalsWithIncompleteProposal[0].getDisplayString());
assertEquals("➕ Continue typing for more proposals...", proposalsWithIncompleteProposal[1].getDisplayString());
}

@Test
public void testIncompleteIndicationWithEmptyList() throws CoreException {
MockLanguageServer.INSTANCE.setCompletionList(new CompletionList(true, List.of()));

IFile testFile = TestUtils.createUniqueTestFile(project, "");
ITextViewer viewer = TestUtils.openTextViewer(testFile);

// without incomplete indication
ICompletionProposal[] proposals = contentAssistProcessor.computeCompletionProposals(viewer, 0);
assertEquals(0, proposals.length);

// with incomplete indication
final var incompleIndicatingProcessor = new LSContentAssistProcessor(true, true);
ICompletionProposal[] proposalsWithIncompleteProposal = incompleIndicatingProcessor.computeCompletionProposals(viewer, 0);
assertEquals(0, proposalsWithIncompleteProposal.length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
}
completeProposals.sort(proposalComparator);
final ICompletionProposal incompleteProposal = createIncompleteProposal(offset, anyIncomplete.get());
if (incompleteProposal != null) {
if (incompleteProposal != null && !completeProposals.isEmpty()) {
// Only add the incompleteProposal if the list is not empty.
// Otherwise we might get a completion popup which contains only the incompleteProposal.

@SuppressWarnings("unchecked")
final var incompleteProposals = (List<ICompletionProposal>) (List<?>) completeProposals;
incompleteProposals.add(incompleteProposal);
Expand Down