mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-30 15:33:59 +00:00
fix long name option completion. close #318
This commit is contained in:
1 parent
db78b670d6
commit
361bda07ef
2 files changed
+11
-4
No files matched your search
@@ -99,7 +99,12 @@ public class CompletionUtils {
|
|||||||
} else {
|
} else {
|
||||||
String commonPrefix = CompletionUtils.findLongestCommonPrefix(candidates);
|
String commonPrefix = CompletionUtils.findLongestCommonPrefix(candidates);
|
||||||
if (commonPrefix.length() > 0) {
|
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 {
|
} else {
|
||||||
completion.complete(candidates);
|
completion.complete(candidates);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,11 @@ class CompletionAdaptor implements Completion {
|
|||||||
CliToken lastToken = tokens.get(tokens.size() - 1);
|
CliToken lastToken = tokens.get(tokens.size() - 1);
|
||||||
if (!commonPrefix.equals(lastToken.value())) {
|
if (!commonPrefix.equals(lastToken.value())) {
|
||||||
// only complete if the common prefix is longer than the last token
|
// only complete if the common prefix is longer than the last token
|
||||||
String strToComplete = commonPrefix.substring(lastToken.value().length());
|
if (commonPrefix.length() > lastToken.value().length()) {
|
||||||
completion.complete(io.termd.core.util.Helper.toCodePoints(strToComplete), false);
|
String strToComplete = commonPrefix.substring(lastToken.value().length());
|
||||||
return;
|
completion.complete(io.termd.core.util.Helper.toCodePoints(strToComplete), false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user