only propose value if the existing prefix is a real prefix
This commit is contained in:
@@ -227,7 +227,7 @@ public class QueryCompletionPdbLangParser extends PdbLangParser {
|
||||
final SortedSet<String> result = new TreeSet<>();
|
||||
|
||||
for (final String value : availableValuesForKey) {
|
||||
if (value.startsWith(propertyValuePrefix)) {
|
||||
if (value.startsWith(propertyValuePrefix) && !value.equals(propertyValuePrefix)) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,14 @@ public class ProposerTest {
|
||||
private void initDatabase() throws Exception {
|
||||
tagsToPath = new LinkedHashMap<>();
|
||||
final Tags eagleTim = Tags.create("bird", "eagle", "name", "Tim");
|
||||
final Tags eagleTimothy = Tags.create("bird", "eagle", "name", "Timothy");
|
||||
final Tags pigeonJennifer = Tags.create("bird", "pigeon", "name", "Jennifer");
|
||||
final Tags flamingoJennifer = Tags.create("bird", "flamingo", "name", "Jennifer");
|
||||
final Tags labradorJenny = Tags.create("dog", "labrador", "name", "Jenny");
|
||||
final Tags labradorTim = Tags.create("dog", "labrador", "name", "Tim");
|
||||
|
||||
tagsToPath.put(eagleTim, null);
|
||||
tagsToPath.put(eagleTimothy, null);
|
||||
tagsToPath.put(pigeonJennifer, null);
|
||||
tagsToPath.put(flamingoJennifer, null);
|
||||
tagsToPath.put(labradorJenny, null);
|
||||
@@ -63,36 +65,43 @@ public class ProposerTest {
|
||||
public void testEmptyQuery() throws Exception {
|
||||
|
||||
assertProposals("", 0, //
|
||||
new Proposal("name", "name=*", 5), //
|
||||
new Proposal("bird", "bird=*", 3), //
|
||||
new Proposal("name", "name=*", 6), //
|
||||
new Proposal("bird", "bird=*", 4), //
|
||||
new Proposal("dog", "dog=*", 2)//
|
||||
);
|
||||
|
||||
assertProposals(" ", 1, //
|
||||
new Proposal("name", "name=*", 5), //
|
||||
new Proposal("bird", "bird=*", 3), //
|
||||
new Proposal("name", "name=*", 6), //
|
||||
new Proposal("bird", "bird=*", 4), //
|
||||
new Proposal("dog", "dog=*", 2)//
|
||||
);
|
||||
}
|
||||
|
||||
public void testPrefixOfKey() throws Exception {
|
||||
assertProposals("bi", 2, //
|
||||
new Proposal("bird", "bird=* ", 3) //
|
||||
new Proposal("bird", "bird=* ", 4) //
|
||||
);
|
||||
assertProposals("bird", 4, //
|
||||
new Proposal("bird", "bird=* ", 3) //
|
||||
new Proposal("bird", "bird=* ", 4) //
|
||||
);
|
||||
}
|
||||
|
||||
public void testPrefixOfValue() throws Exception {
|
||||
assertProposals("name =Tim", 9, //
|
||||
new Proposal("Timothy", "name =Timothy ", 1)
|
||||
);
|
||||
|
||||
/*
|
||||
assertProposals("name =Je", 8, //
|
||||
new Proposal("Jennifer", "name =Jennifer ", 2), //
|
||||
new Proposal("Jenny", "name =Jenny ", 1) //
|
||||
);
|
||||
|
||||
|
||||
assertProposals("bird=eagle and n", 16, //
|
||||
new Proposal("name", "bird=eagle and name=* ", 1) //
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
private void assertProposals(final String query, final int caretIndex, final Proposal... expected)
|
||||
|
||||
Reference in New Issue
Block a user