Skip to content

Commit

Permalink
Builtins: do not create a new NullCompleters use
Browse files Browse the repository at this point in the history
NullCompleter.INSTANCE
  • Loading branch information
mattirn committed Nov 19, 2019
1 parent cb6593a commit 733b3e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions builtins/src/main/java/org/jline/builtins/Builtins.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,25 +389,25 @@ private List<Completer> lessCompleter(String name) {
private List<Completer> historyCompleter(String name) {
List<Completer> completers = new ArrayList<>();
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new OptionCompleter(new NullCompleter()
, new OptionCompleter(NullCompleter.INSTANCE
, this::commandOptions
, 1)
));
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new StringsCompleter(Arrays.asList("-A", "-W", "-R", "-AI", "-RI", "-WI")), new FilesCompleter(workDir.get(), true), new NullCompleter()));
, new StringsCompleter(Arrays.asList("-A", "-W", "-R", "-AI", "-RI", "-WI")), new FilesCompleter(workDir.get(), true), NullCompleter.INSTANCE));
return completers;
}

private List<Completer> widgetCompleter(String name) {
List<Completer> completers = new ArrayList<>();
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new OptionCompleter(new NullCompleter()
, new OptionCompleter(NullCompleter.INSTANCE
, this::commandOptions
, 1)
));
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new StringsCompleter("-A"), new StringsCompleter(() -> allWidgets())
, new StringsCompleter(() -> reader.getWidgets().keySet()), new NullCompleter()));
, new StringsCompleter(() -> reader.getWidgets().keySet()), NullCompleter.INSTANCE));
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new StringsCompleter("-D"), new StringsCompleter(() -> reader.getWidgets().keySet())));
return completers;
Expand All @@ -416,7 +416,7 @@ private List<Completer> widgetCompleter(String name) {
private List<Completer> keymapCompleter(String name) {
List<Completer> completers = new ArrayList<>();
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new OptionCompleter(new NullCompleter()
, new OptionCompleter(NullCompleter.INSTANCE
, this::commandOptions
, 1)
));
Expand All @@ -426,7 +426,7 @@ private List<Completer> keymapCompleter(String name) {
private List<Completer> setvarCompleter(String name) {
List<Completer> completers = new ArrayList<>();
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new StringsCompleter(() -> reader.getVariables().keySet()), new NullCompleter()));
, new StringsCompleter(() -> reader.getVariables().keySet()), NullCompleter.INSTANCE));
return completers;
}

Expand All @@ -447,7 +447,7 @@ private List<Completer> unsetoptCompleter(String name) {
private List<Completer> ttopCompleter(String name) {
List<Completer> completers = new ArrayList<>();
completers.add(new ArgumentCompleter(new StringsCompleter(name)
, new OptionCompleter(new NullCompleter()
, new OptionCompleter(NullCompleter.INSTANCE
, this::commandOptions
, 1)
));
Expand Down
2 changes: 2 additions & 0 deletions builtins/src/main/java/org/jline/builtins/Completers.java
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ public void complete(LineReader reader, final ParsedLine commandLine, List<Candi
}
if (args < argsCompleters.size()) {
argsCompleters.get(args).complete(reader, commandLine, candidates);
} else {
argsCompleters.get(argsCompleters.size() - 1).complete(reader, commandLine, candidates);
}
} else {
argsCompleters.get(0).complete(reader, commandLine, candidates);
Expand Down

0 comments on commit 733b3e1

Please sign in to comment.