Fixes some problems with TabCompletionHelper.getStringList
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
This commit is contained in:
parent
1d6a3f976e
commit
5427e2a401
@ -50,7 +50,7 @@ public final class TabCompletionHelper {
|
|||||||
|
|
||||||
// Filter available values by the text after the last comma only
|
// Filter available values by the text after the last comma only
|
||||||
List<String> filtered;
|
List<String> filtered;
|
||||||
if (filterer != null) {
|
if (filterer != null && !typedText.endsWith(",")) {
|
||||||
filtered = filterer.apply(new ArrayList<>(values), lastArgument);
|
filtered = filterer.apply(new ArrayList<>(values), lastArgument);
|
||||||
} else {
|
} else {
|
||||||
filtered = values;
|
filtered = values;
|
||||||
|
@ -36,6 +36,15 @@ public class TabCompletionHelperTest {
|
|||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getStringListContainsTest2() {
|
||||||
|
List<String> input = List.of("ape", "ball", "car", "donut");
|
||||||
|
List<String> result = TabCompletionHelper.getStringList(input, "ball,donut,",
|
||||||
|
TabCompletionHelper::filterMatchingContains);
|
||||||
|
List<String> expected = List.of("ball,donut,ape", "ball,donut,car");
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getStringListStartsWithTest() {
|
public void getStringListStartsWithTest() {
|
||||||
List<String> input = List.of("ape", "ball", "car", "donut");
|
List<String> input = List.of("ape", "ball", "car", "donut");
|
||||||
@ -45,4 +54,29 @@ public class TabCompletionHelperTest {
|
|||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getStringListStartsWithTest2() {
|
||||||
|
List<String> input = List.of("ape", "ball", "car", "donut");
|
||||||
|
List<String> result = TabCompletionHelper.getStringList(input, "ball,donut,",
|
||||||
|
TabCompletionHelper::filterMatchingStartsWith);
|
||||||
|
List<String> expected = List.of("ball,donut,ape", "ball,donut,car");
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void filterMatchingContainsTest() {
|
||||||
|
List<String> input = List.of("fish", "ape", "banana", "toy", "human", "stick", "potato", "detergent", "magazine");
|
||||||
|
List<String> result = TabCompletionHelper.filterMatchingContains(input, "a");
|
||||||
|
List<String> expected = List.of("ape", "banana", "human", "potato", "magazine");
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void filterMatchingStartsWithTest() {
|
||||||
|
List<String> input = List.of("fish", "ape", "banana", "toy", "human", "stick", "potato", "detergent", "magazine");
|
||||||
|
List<String> result = TabCompletionHelper.filterMatchingStartsWith(input, "a");
|
||||||
|
List<String> expected = List.of("ape");
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user