Merge pull request #2228 from Minecrell/patch-2
Fix some issues with the console command completion
This commit is contained in:
commit
cef50616d8
2 changed files with 15 additions and 13 deletions
|
@ -2,6 +2,7 @@ package net.minecraftforge.server.console;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -28,14 +29,9 @@ public final class ConsoleCommandCompleter implements Completer
|
|||
public int complete(String buffer, int cursor, List<CharSequence> candidates)
|
||||
{
|
||||
int len = buffer.length();
|
||||
buffer = buffer.trim();
|
||||
if (buffer.isEmpty())
|
||||
{
|
||||
return cursor;
|
||||
}
|
||||
|
||||
boolean prefix;
|
||||
if (buffer.charAt(0) != '/')
|
||||
if (buffer.isEmpty() || buffer.charAt(0) != '/')
|
||||
{
|
||||
buffer = '/' + buffer;
|
||||
prefix = false;
|
||||
|
@ -59,6 +55,7 @@ public final class ConsoleCommandCompleter implements Completer
|
|||
try
|
||||
{
|
||||
List<String> completions = tabComplete.get();
|
||||
Collections.sort(completions);
|
||||
if (prefix)
|
||||
{
|
||||
candidates.addAll(completions);
|
||||
|
@ -76,6 +73,10 @@ public final class ConsoleCommandCompleter implements Completer
|
|||
{
|
||||
return cursor - len;
|
||||
}
|
||||
else if (prefix)
|
||||
{
|
||||
return cursor - len + pos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cursor - len + pos;
|
||||
|
|
|
@ -34,16 +34,17 @@ public final class TerminalHandler
|
|||
try
|
||||
{
|
||||
line = reader.readLine("> ");
|
||||
|
||||
if (line != null)
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
line = line.trim();
|
||||
if (!line.isEmpty())
|
||||
{
|
||||
server.addPendingCommand(line, server);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Exception handling console input", e);
|
||||
|
|
Loading…
Reference in a new issue