When we redirect, add initial node to the context

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

No files matched your search

@@ -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);
}
@@ -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;
}