When we redirect, add initial node to the context
This commit is contained in:
@@ -109,7 +109,7 @@ public class CommandDispatcher<S> {
|
|||||||
if (reader.canRead()) {
|
if (reader.canRead()) {
|
||||||
reader.skip();
|
reader.skip();
|
||||||
if (child.getRedirect() != null) {
|
if (child.getRedirect() != null) {
|
||||||
return parseNodes(child.getRedirect(), reader, context.redirect());
|
return parseNodes(child.getRedirect(), reader, context.redirect(child.getRedirect()));
|
||||||
} else {
|
} else {
|
||||||
return parseNodes(child, reader, context);
|
return parseNodes(child, reader, context);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ public class CommandContextBuilder<S> {
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandContextBuilder<S> redirect() {
|
public CommandContextBuilder<S> redirect(final CommandNode<S> newRoot) {
|
||||||
final CommandContextBuilder<S> result = new CommandContextBuilder<>(dispatcher, source);
|
final CommandContextBuilder<S> result = new CommandContextBuilder<>(dispatcher, source);
|
||||||
|
result.withNode(newRoot, "");
|
||||||
result.parent = build();
|
result.parent = build();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user