diff options
author | Lucas Bullen | 2018-01-12 15:40:14 +0000 |
---|---|---|
committer | Karsten Thoms | 2018-01-16 05:49:26 +0000 |
commit | ef65f1a268cc14a0e7967532f7557ffde0606bc3 (patch) | |
tree | b22840c37d68f2ec5e7b973aabae43c493cc1643 | |
parent | 2183a59b883e704e492ccf30f7ee15613b42a81d (diff) | |
download | eclipse.platform.ui-ef65f1a268cc14a0e7967532f7557ffde0606bc3.tar.gz eclipse.platform.ui-ef65f1a268cc14a0e7967532f7557ffde0606bc3.tar.xz eclipse.platform.ui-ef65f1a268cc14a0e7967532f7557ffde0606bc3.zip |
Bug 529660 - Open resource dialog should follow terminating highlighting
- Searches ending in '<' or ' ' do not match trailing chars
Change-Id: Ida10b616c669a46c3d051e3ba4668e1138edee1a
Signed-off-by: Lucas Bullen <lbullen@redhat.com>
2 files changed, 26 insertions, 0 deletions
diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java index d8306e338bc..e5c4de71d97 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java @@ -679,6 +679,16 @@ public class FilteredResourcesSelectionDialog extends private List<Position> getMatchPositions(String string, String matching) { final String originalMatching = matching; List<Position> positions = new ArrayList<>(); + if (matching.length() == 0 || string.length() == 0) { + return positions; + } + + char lastChar = matching.charAt(matching.length() - 1); + if (lastChar == ' ') { + matching = matching.substring(0, matching.length() - 1); + } else if (lastChar == '<') { + matching = matching.substring(0, matching.length() - 2); + } if (matching.indexOf('?') == -1 && matching.indexOf('*') == -1) { matching = String.join("*", matching.split("(?=[A-Z0-9])")) + "*"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ } else { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java index ad78fd24ec6..408e957bdf2 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceItemLabelTest.java @@ -130,6 +130,22 @@ public class ResourceItemLabelTest extends UITestCase { } /** + * Tests that the highlighting matches searches using '<' and ' ' + * + * @throws Exception + */ + public void testDisableAutoPrefixMatching() throws Exception { + Position[] questionMark = { new Position(0, 1), new Position(4, 4) }; + compareStyleRanges(questionMark, getStyleRanges("M*file<", "Makefile")); + + Position[] star = { new Position(0, 1), new Position(4, 4) }; + compareStyleRanges(star, getStyleRanges("M*file ", "MockFile")); + + Position[] both = { new Position(0, 3), new Position(6, 1) }; + compareStyleRanges(both, getStyleRanges("CreS<", "CreateStuff.java")); + } + + /** * Tests that the highlighting matches extension searches * * @throws Exception |