Skip to content

Commit

Permalink
TailTipWidgets: simplified if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Jun 21, 2020
1 parent 96defb8 commit 915e942
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions console/src/main/java/org/jline/widget/TailTipWidgets.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,23 +697,19 @@ private Pair<String,Boolean> evaluateCommandLine(String line, List<String> args,
}
}
}
if (cmd != null && descFun != null) {
if (!descriptionCache && descType == CmdLine.DescriptionType.COMMAND) {
CmdDesc c = descFun.apply(new CmdLine(line, head, tail, args, descType));
volatileDescs.put(cmd, c);
} else if (!descriptions.containsKey(cmd) && !temporaryDescs.containsKey(cmd)) {
if (descType == CmdLine.DescriptionType.COMMAND) {
CmdDesc c = descFun.apply(new CmdLine(line, head, tail, args, descType));
if (c != null) {
descriptions.put(cmd, c);
} else {
temporaryDescs.put(cmd, c);
}
} else if (descType == CmdLine.DescriptionType.METHOD) {
temporaryDescs.put(cmd, descFun.apply(new CmdLine(line, head, tail, args, descType)));
if (cmd != null && descFun != null
&& !descriptions.containsKey(cmd) && !temporaryDescs.containsKey(cmd)) {
CmdDesc c = descFun.apply(new CmdLine(line, head, tail, args, descType));
if (descType == CmdLine.DescriptionType.COMMAND) {
if (!descriptionCache) {
volatileDescs.put(cmd, c);
} else if (c != null) {
descriptions.put(cmd, c);
} else {
temporaryDescs.put(cmd, descFun.apply(new CmdLine(line, head, tail, args, descType)));
temporaryDescs.put(cmd, c);
}
} else {
temporaryDescs.put(cmd, c);
}
}
return new Pair<String,Boolean>(cmd, descType == CmdLine.DescriptionType.COMMAND ? true : false);
Expand All @@ -733,7 +729,7 @@ public CmdDesc getDescription(String command) {
}

public void clearTemporaryDescs() {
temporaryDescs = new HashMap<>();
temporaryDescs.clear();
}

}
Expand Down

0 comments on commit 915e942

Please # to comment.