When we redirect, add initial node to the context

This commit is contained in:
Nathan Adams 2017-08-10 09:03:10 +02:00
parent 78f4187908
commit 9c5af32afa
2 changed files with 3 additions and 2 deletions

View file

@ -109,7 +109,7 @@ public class CommandDispatcher<S> {
if (reader.canRead()) {
reader.skip();
if (child.getRedirect() != null) {
return parseNodes(child.getRedirect(), reader, context.redirect());
return parseNodes(child.getRedirect(), reader, context.redirect(child.getRedirect()));
} else {
return parseNodes(child, reader, context);
}

View file

@ -63,8 +63,9 @@ public class CommandContextBuilder<S> {
return copy;
}
public CommandContextBuilder<S> redirect() {
public CommandContextBuilder<S> redirect(final CommandNode<S> newRoot) {
final CommandContextBuilder<S> result = new CommandContextBuilder<>(dispatcher, source);
result.withNode(newRoot, "");
result.parent = build();
return result;
}