diff --git a/core/src/main/java/com/taobao/arthas/core/shell/term/impl/CompletionAdaptor.java b/core/src/main/java/com/taobao/arthas/core/shell/term/impl/CompletionAdaptor.java index b0fcb27b088..2d03ea877e0 100644 --- a/core/src/main/java/com/taobao/arthas/core/shell/term/impl/CompletionAdaptor.java +++ b/core/src/main/java/com/taobao/arthas/core/shell/term/impl/CompletionAdaptor.java @@ -4,6 +4,7 @@ import com.taobao.arthas.core.shell.cli.Completion; import com.taobao.arthas.core.shell.cli.CompletionUtils; import com.taobao.arthas.core.shell.session.Session; +import com.taobao.arthas.core.util.StringUtils; import java.util.LinkedList; import java.util.List; @@ -42,15 +43,18 @@ public List lineTokens() { @Override public void complete(List candidates) { + String lastToken = tokens.get(tokens.size() - 1).value(); + if(StringUtils.isBlank(lastToken)) { + lastToken = ""; + } if (candidates.size() > 1) { // complete common prefix String commonPrefix = CompletionUtils.findLongestCommonPrefix(candidates); if (commonPrefix.length() > 0) { - CliToken lastToken = tokens.get(tokens.size() - 1); - if (!commonPrefix.equals(lastToken.value())) { + if (!commonPrefix.equals(lastToken)) { // only complete if the common prefix is longer than the last token - if (commonPrefix.length() > lastToken.value().length()) { - String strToComplete = commonPrefix.substring(lastToken.value().length()); + if (commonPrefix.length() > lastToken.length()) { + String strToComplete = commonPrefix.substring(lastToken.length()); completion.complete(io.termd.core.util.Helper.toCodePoints(strToComplete), false); return; }