mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
fix long name option completion. close #318
This commit is contained in:
@@ -99,7 +99,12 @@ public class CompletionUtils {
|
||||
} else {
|
||||
String commonPrefix = CompletionUtils.findLongestCommonPrefix(candidates);
|
||||
if (commonPrefix.length() > 0) {
|
||||
completion.complete(commonPrefix, false);
|
||||
if (commonPrefix.length() == prefix.length()) {
|
||||
completion.complete(candidates);
|
||||
} else {
|
||||
completion.complete(commonPrefix.substring(prefix.length(), commonPrefix.length()), false);
|
||||
}
|
||||
|
||||
} else {
|
||||
completion.complete(candidates);
|
||||
}
|
||||
|
||||
@@ -49,9 +49,11 @@ class CompletionAdaptor implements Completion {
|
||||
CliToken lastToken = tokens.get(tokens.size() - 1);
|
||||
if (!commonPrefix.equals(lastToken.value())) {
|
||||
// only complete if the common prefix is longer than the last token
|
||||
String strToComplete = commonPrefix.substring(lastToken.value().length());
|
||||
completion.complete(io.termd.core.util.Helper.toCodePoints(strToComplete), false);
|
||||
return;
|
||||
if (commonPrefix.length() > lastToken.value().length()) {
|
||||
String strToComplete = commonPrefix.substring(lastToken.value().length());
|
||||
completion.complete(io.termd.core.util.Helper.toCodePoints(strToComplete), false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user