Fixed commands with a trailing whitespace
This commit is contained in:
@@ -153,7 +153,9 @@ public class CommandDispatcher<S> {
|
||||
|
||||
context.withCommand(child.getCommand());
|
||||
if (reader.canRead()) {
|
||||
reader.skip();
|
||||
if (reader.canRead(2)) {
|
||||
reader.skip();
|
||||
}
|
||||
if (child.getRedirect() != null) {
|
||||
final CommandContextBuilder<S> childContext = new CommandContextBuilder<>(this, source, reader.getCursor());
|
||||
childContext.withNode(child.getRedirect(), new StringRange(reader.getCursor(), reader.getCursor()));
|
||||
|
||||
@@ -173,6 +173,16 @@ public class CommandDispatcherTest {
|
||||
verify(subCommand).run(any(CommandContext.class));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testParseIncomplete() throws Exception {
|
||||
subject.register(literal("foo").then(literal("bar").executes(command)));
|
||||
|
||||
final ParseResults<Object> parse = subject.parse("foo ", source);
|
||||
assertThat(parse.getReader().getRemaining(), equalTo(" "));
|
||||
assertThat(parse.getContext().getNodes().size(), is(1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testExecuteAmbiguiousParentSubcommand() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user