Skip to content

Commit

Permalink
Use CompletionMatcher also in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Dec 23, 2020
1 parent 89d4ec4 commit a6e31a1
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
Expand Up @@ -4951,10 +4951,9 @@ protected boolean doList(List<Candidate> possible
String current = completed + sb.toString();
List<Candidate> cands;
if (sb.length() > 0) {
cands = possible.stream()
.filter(c -> caseInsensitive
? c.value().toLowerCase().startsWith(current.toLowerCase())
: c.value().startsWith(current))
completionMatcher.compile(options, false, new CompletingWord(current), caseInsensitive
, getInt(LineReader.ERRORS, DEFAULT_ERRORS), getOriginalGroupName());
cands = completionMatcher.matches(possible).stream()
.sorted(getCandidateComparator(caseInsensitive, current))
.collect(Collectors.toList());
} else {
Expand Down Expand Up @@ -5031,6 +5030,59 @@ protected boolean doList(List<Candidate> possible
}
}

private static class CompletingWord implements CompletingParsedLine {
private final String word;

public CompletingWord(String word) {
this.word = word;
}

@Override
public CharSequence escape(CharSequence candidate, boolean complete) {
return null;
}

@Override
public int rawWordCursor() {
return word.length();
}

@Override
public int rawWordLength() {
return word.length();
}

@Override
public String word() {
return word;
}

@Override
public int wordCursor() {
return word.length();
}

@Override
public int wordIndex() {
return 0;
}

@Override
public List<String> words() {
return null;
}

@Override
public String line() {
return word;
}

@Override
public int cursor() {
return word.length();
}
}

protected static class PostResult {
final AttributedString post;
final int lines;
Expand Down

0 comments on commit a6e31a1

Please sign in to comment.