When we redirect, add initial node to the context
This commit is contained in:
parent
78f4187908
commit
9c5af32afa
2 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue