Skip to content

Commit

Permalink
Support an empty value as a Candidate that only suggests but doesn't …
Browse files Browse the repository at this point in the history
…complete, fixes #89
  • Loading branch information
gnodet committed Jan 13, 2017
1 parent 6f7a2e5 commit 2144e6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion builtins/src/test/java/org/jline/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ public static void main(String[] args) throws IOException {
case "foo":
completer = new ArgumentCompleter(
new StringsCompleter("foo11", "foo12", "foo13"),
new StringsCompleter("foo21", "foo22", "foo23"));
new StringsCompleter("foo21", "foo22", "foo23"),
new Completer() {
@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
candidates.add(new Candidate("", "", null, "frequency in MHz", null, null, false));
}
});
break label;
case "param":
completer = (reader, line, candidates) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3751,7 +3751,7 @@ else if (isSet(Option.RECOGNIZE_EXACT)) {
.findFirst().orElse(null);
}
// Complete and exit
if (completion != null) {
if (completion != null && !completion.value().isEmpty()) {
if (prefix) {
buf.backspace(line.wordCursor());
} else {
Expand Down

0 comments on commit 2144e6a

Please # to comment.