diff --git a/build.gradle b/build.gradle index 2d868ad9..0b2d68be 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import groovy.io.FileType apply plugin: 'java-library' apply plugin: 'maven' -version = '0.1.1' +version = '0.1.2' group = 'com.mojang' task wrapper(type: Wrapper) { diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java index 5bca273c..25193be4 100644 --- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java +++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java @@ -153,7 +153,9 @@ private ParseResults parseNodes(final CommandNode node, final StringReader context.withCommand(child.getCommand()); if (reader.canRead()) { - reader.skip(); + if (reader.canRead(2)) { + reader.skip(); + } if (child.getRedirect() != null) { final CommandContextBuilder childContext = new CommandContextBuilder<>(this, source, reader.getCursor()); childContext.withNode(child.getRedirect(), new StringRange(reader.getCursor(), reader.getCursor())); diff --git a/src/test/java/com/mojang/brigadier/CommandDispatcherTest.java b/src/test/java/com/mojang/brigadier/CommandDispatcherTest.java index 651dfdd7..3352b479 100644 --- a/src/test/java/com/mojang/brigadier/CommandDispatcherTest.java +++ b/src/test/java/com/mojang/brigadier/CommandDispatcherTest.java @@ -173,6 +173,16 @@ public void testExecuteSubcommand() throws Exception { 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 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 {