diff --git a/command.fnl b/command.fnl index a918ebd..e3d0c85 100644 --- a/command.fnl +++ b/command.fnl @@ -122,8 +122,9 @@ (if (not result.active) (completions-widget:hide)) (set entry.text (or result.default result.error "")) - (widget.parent:set_visible_child_name - (if result.active "commander" "echo-area"))) + (when widget.parent + (widget.parent:set_visible_child_name + (if result.active "commander" "echo-area")))) (fn on-input [self str] (match self.state diff --git a/test/command.fnl b/test/command.fnl index dc11508..8982661 100644 --- a/test/command.fnl +++ b/test/command.fnl @@ -20,7 +20,7 @@ (let [commander (Command.commander) (ok err) (match-try (commander:activate) - {:active true} (commander:on-activate "not-a-command") + {:active true} (commander:on-input-finished "not-a-command") (where {:error e :active false} (e:match "can't find command")) true (catch x (values nil (view x))))] @@ -30,9 +30,9 @@ (let [commander (Command.commander) (ok err) (match-try (commander:activate) - {:active true} (commander:on-activate "multiply") - {:active true :prompt p1} (commander:on-activate "2") - {:active true :prompt p2} (commander:on-activate "3") + {:active true} (commander:on-input-finished "multiply") + {:active true :prompt p1} (commander:on-input-finished "2") + {:active true :prompt p2} (commander:on-input-finished "3") (where {:active false} (= happened 6)) true (catch x (values nil (view x))))]