Sort suggestions case-insensitively

This commit is contained in:
Nathan Adams 2018-02-05 15:57:01 +01:00
parent 182168acd5
commit 2def16ba85
2 changed files with 4 additions and 4 deletions

View file

@ -97,7 +97,7 @@ public class Suggestions {
texts.add(suggestion.expand(command, range)); texts.add(suggestion.expand(command, range));
} }
final List<String> sorted = Lists.newArrayList(texts); final List<String> sorted = Lists.newArrayList(texts);
Collections.sort(sorted); sorted.sort(String::compareToIgnoreCase);
return new Suggestions(range, sorted); return new Suggestions(range, sorted);
} }
} }

View file

@ -26,9 +26,9 @@ public class SuggestionsTest {
@Test @Test
public void merge_multiple() { public void merge_multiple() {
final Suggestions a = new Suggestions(StringRange.at(5), Lists.newArrayList("ar", "az")); final Suggestions a = new Suggestions(StringRange.at(5), Lists.newArrayList("ar", "az", "Az"));
final Suggestions b = new Suggestions(StringRange.between(4, 5), Lists.newArrayList("foo", "qux", "apple")); final Suggestions b = new Suggestions(StringRange.between(4, 5), Lists.newArrayList("foo", "qux", "apple", "Bar"));
final Suggestions merged = Suggestions.merge("foo b", Lists.newArrayList(a, b)); final Suggestions merged = Suggestions.merge("foo b", Lists.newArrayList(a, b));
assertThat(merged.getList(), equalTo(Lists.newArrayList("apple", "bar", "baz", "foo", "qux"))); assertThat(merged.getList(), equalTo(Lists.newArrayList("apple", "bar", "Bar", "baz", "bAz", "foo", "qux")));
} }
} }