Skip to content

Commit

Permalink
SystemCompleter: added null check and test for variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Dec 18, 2019
1 parent 0e537cb commit 78368e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtins/src/main/java/org/jline/builtins/Completers.java
Expand Up @@ -23,6 +23,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
Expand Down Expand Up @@ -590,7 +591,7 @@ public void complete(LineReader reader, ParsedLine commandLine, List<Candidate>
int eq = buffer.indexOf('=');
if (eq < 0) {
commands.complete(reader, commandLine, candidates);
} else {
} else if (buffer.substring(0, eq).matches("[a-zA-Z]{1,}[a-zA-Z0-9]*")) {
String curBuf = buffer.substring(0, eq + 1);
for (String c: completers.keySet()) {
candidates.add(new Candidate(AttributedString.stripAnsi(curBuf+c)
Expand Down Expand Up @@ -633,6 +634,7 @@ public void add(List<String> commands, org.jline.reader.Completer completer) {
}

public void add(String command, org.jline.reader.Completer completer) {
Objects.requireNonNull(command);
if (compiled) {
throw new IllegalStateException();
}
Expand Down

0 comments on commit 78368e4

Please sign in to comment.