Fixed from failing prematurely on partially matching literals

This commit is contained in:
Nathan Adams
2017-08-07 09:24:14 +02:00
parent 2d7644dce3
commit 78f4187908
2 changed files with 17 additions and 3 deletions
@@ -94,6 +94,11 @@ public class CommandDispatcher<S> {
final int cursor = reader.getCursor();
try {
child.parse(reader, context);
if (reader.canRead()) {
if (reader.peek() != ARGUMENT_SEPARATOR_CHAR) {
throw ERROR_EXPECTED_ARGUMENT_SEPARATOR.createWithContext(reader);
}
}
} catch (final CommandException ex) {
errors.put(child, ex);
reader.setCursor(cursor);
@@ -102,9 +107,6 @@ public class CommandDispatcher<S> {
context.withCommand(child.getCommand());
if (reader.canRead()) {
if (reader.peek() != ARGUMENT_SEPARATOR_CHAR) {
throw ERROR_EXPECTED_ARGUMENT_SEPARATOR.createWithContext(reader);
}
reader.skip();
if (child.getRedirect() != null) {
return parseNodes(child.getRedirect(), reader, context.redirect());