YetAnotherConfigLib

YetAnotherConfigLib

13M Downloads

String dropdowns prioritize capitalization over starting with

kevinthegreat1 opened this issue ยท 0 comments

commented

Options containing the correct capitalization can be prioritized over options that starts with the string.

Example

Screenshot 2023-10-02 at 22 31 50

Analysis

In AbstractDropdownController#getValidValue, the filter calls value.toLowerCase() but the checks in sorted() does not call toLowerCase().

return getAllowedValues(value).stream()
		.filter(val -> val.toLowerCase().contains(value.toLowerCase()))
		.sorted((s1, s2) -> {
			if (s1.startsWith(value) && !s2.startsWith(value)) return -1;
			if (!s1.startsWith(value) && s2.startsWith(value)) return 1;
			return s1.compareTo(s2);
		})
		.skip(offset)
		.findFirst()
		.orElseGet(this::getString);