Skip to content

Commit

Permalink
TailTipWidgets option usage goes away when writing its argument, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Dec 15, 2023
1 parent f3c60a3 commit c275b40
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions console/src/main/java/org/jline/widget/TailTipWidgets.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2021, the original author(s).
* Copyright (c) 2002-2023, the original author(s).
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -322,25 +322,22 @@ private void doCommandTailTip(String widget, CmdDesc cmdDesc, List<String> args)
doDescription(compileMainDescription(cmdDesc, descriptionSize));
}
if (cmdDesc != null) {
if (lastArg.startsWith("-")) {
if (lastArg.matches("-[a-zA-Z][a-zA-Z0-9]+")) {
if (cmdDesc.optionWithValue(lastArg.substring(0, 2))) {
doDescription(compileOptionDescription(cmdDesc, lastArg.substring(0, 2), descriptionSize));
setTipType(tipType);
} else {
doDescription(compileOptionDescription(
cmdDesc, "-" + lastArg.substring(lastArg.length() - 1), descriptionSize));
setSuggestionType(SuggestionType.TAIL_TIP);
noCompleters = true;
}
if (prevArg.startsWith("-")
&& !prevArg.contains("=")
&& !prevArg.matches("-[a-zA-Z][\\S]+")
&& cmdDesc.optionWithValue(prevArg)) {
doDescription(compileOptionDescription(cmdDesc, prevArg, descriptionSize));
setTipType(tipType);
} else if (lastArg.matches("-[a-zA-Z][\\S]+") && cmdDesc.optionWithValue(lastArg.substring(0, 2))) {
doDescription(compileOptionDescription(cmdDesc, lastArg.substring(0, 2), descriptionSize));
setTipType(tipType);
} else if (lastArg.startsWith("-")) {
doDescription(compileOptionDescription(cmdDesc, lastArg, descriptionSize));
if (!lastArg.contains("=")) {
setSuggestionType(SuggestionType.TAIL_TIP);
noCompleters = true;
} else {
doDescription(compileOptionDescription(cmdDesc, lastArg, descriptionSize));
if (!lastArg.contains("=")) {
setSuggestionType(SuggestionType.TAIL_TIP);
noCompleters = true;
} else {
setTipType(tipType);
}
setTipType(tipType);
}
} else if (!widget.endsWith(LineReader.BACKWARD_DELETE_CHAR)) {
setTipType(tipType);
Expand All @@ -354,7 +351,7 @@ private void doCommandTailTip(String widget, CmdDesc cmdDesc, List<String> args)
if (bpsize - 1 < params.size()) {
if (!lastArg.startsWith("-")) {
List<AttributedString> d;
if (!prevArg.matches("-[a-zA-Z]") || !cmdDesc.optionWithValue(prevArg)) {
if (!prevArg.startsWith("-") || !cmdDesc.optionWithValue(prevArg)) {
d = params.get(bpsize - 1).getDescription();
} else {
d = compileOptionDescription(cmdDesc, prevArg, descriptionSize);
Expand Down

0 comments on commit c275b40

Please sign in to comment.