Skip to content

Commit 6281ee7

Browse files
FlorianKroissrubenporras
authored andcommitted
fix: Show incomplete indicator only if completion list is not empty
1 parent f2a7e90 commit 6281ee7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/completion/IncompleteCompletionTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,4 +675,21 @@ public void testIncompleteIndication() throws CoreException {
675675
assertEquals("FirstClass", proposalsWithIncompleteProposal[0].getDisplayString());
676676
assertEquals("➕ Continue typing for more proposals...", proposalsWithIncompleteProposal[1].getDisplayString());
677677
}
678+
679+
@Test
680+
public void testIncompleteIndicationWithEmptyList() throws CoreException {
681+
MockLanguageServer.INSTANCE.setCompletionList(new CompletionList(true, List.of()));
682+
683+
IFile testFile = TestUtils.createUniqueTestFile(project, "");
684+
ITextViewer viewer = TestUtils.openTextViewer(testFile);
685+
686+
// without incomplete indication
687+
ICompletionProposal[] proposals = contentAssistProcessor.computeCompletionProposals(viewer, 0);
688+
assertEquals(0, proposals.length);
689+
690+
// with incomplete indication
691+
final var incompleIndicatingProcessor = new LSContentAssistProcessor(true, true);
692+
ICompletionProposal[] proposalsWithIncompleteProposal = incompleIndicatingProcessor.computeCompletionProposals(viewer, 0);
693+
assertEquals(0, proposalsWithIncompleteProposal.length);
694+
}
678695
}

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/completion/LSContentAssistProcessor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
189189
}
190190
completeProposals.sort(proposalComparator);
191191
final ICompletionProposal incompleteProposal = createIncompleteProposal(offset, anyIncomplete.get());
192-
if (incompleteProposal != null) {
192+
if (incompleteProposal != null && !completeProposals.isEmpty()) {
193+
// Only add the incompleteProposal if the list is not empty.
194+
// Otherwise we might get a completion popup which contains only the incompleteProposal.
195+
193196
@SuppressWarnings("unchecked")
194197
final var incompleteProposals = (List<ICompletionProposal>) (List<?>) completeProposals;
195198
incompleteProposals.add(incompleteProposal);

0 commit comments

Comments
 (0)