Bug 542433: [WorkbenchLauncher] Error sound while editing workspace path
Finding no proposals triggers an error sound by default.
Returning "null" from IContentProposalProvider#getProposals
when no proposals could be found doesn't trigger the sound.
Change-Id: Idec663bd32f22321882512e7d457816d4d700a5d
Signed-off-by: Fabian Pfaff <fabian.pfaff@vogella.com>
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java
index 9b504cf..10ce5a2 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java
@@ -75,15 +75,16 @@
@Override
public IContentProposal[] getProposals(String contents, int position) {
if (position == 0) {
- return new IContentProposal[0];
+ return null;
}
String substring = contents.substring(0, position);
Pattern pattern = Pattern.compile(substring,
Pattern.LITERAL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);
- return proposals.stream()
+ IContentProposal[] filteredProposals = proposals.stream()
.filter(proposal -> proposal.length() >= substring.length() && pattern.matcher(proposal).find())
.map(ContentProposal::new)
.toArray(IContentProposal[]::new);
+ return filteredProposals.length == 0 ? null : filteredProposals;
}
/**