in src/org/jetbrains/r/visualization/inlays/table/filters/gui/editor/ChoicesListModel.java [153:194]
public ChoiceMatch getBestMatch(Object hint) {
String str = null;
if (!renderedContent && (hint instanceof String)) {
// is a string (what the user enters), but if there is a format, it
// can correspond to an existing element. For example, the right
// format being for a date "07/05/12", but the user enters
// "7/5/12". In this case, we should automatically return the
// updated string. For the time being, this conversion is not yet
// made (requires changes on the EditorComponent, and side effects
// must be checked...)
str = (String) hint;
hint = null; // for the time being, we
}
Choice choice = new Choice(hint, str);
ChoiceMatch ret = new ChoiceMatch();
Choice match = (hint == null) ? null : content.floor(choice);
if ((match != null) && match.equals(choice)) {
flatContent(); // ensure that the positions are calculated
ret.content = match.get(renderedContent);
ret.index = match.idx;
ret.exact = true;
} else if (!renderedContent) {
TreeSet<Choice> alphaContent = getAlphabeticallySortedContent();
Choice top = alphaContent.ceiling(choice);
Choice low = alphaContent.floor(choice);
int len = choice.str.length();
int clen = (top == null)
? -1
: ChoiceMatch.getMatchingLength(top.str, choice.str,
strComparator);
int flen = (low == null)
? -1
: ChoiceMatch.getMatchingLength(low.str, choice.str,
strComparator);
match = (clen > flen) ? top : low;
ret.index = match.idx;
ret.content = match.get(renderedContent);
ret.len = Math.max(clen, flen);
ret.exact = (match.str.length() == ret.len) && (len == 0 || ret.len > 0);
}
return ret;
}