From: Matt S Trout Date: Sat, 5 Mar 2016 07:51:52 +0000 (+0000) Subject: find solution on proposition addition and output actions run X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=31d445d30856f1284edc9c82c04544167f1585e9;p=scpubgit%2FDX.git find solution on proposition addition and output actions run --- diff --git a/lib/DX/QueryState.pm b/lib/DX/QueryState.pm index 68f4638..dcc79c7 100644 --- a/lib/DX/QueryState.pm +++ b/lib/DX/QueryState.pm @@ -61,9 +61,12 @@ sub with_additional_proposition { my ($self, $prop) = @_; my $prop_seq = $self->proposition_sequence ->but_append_proposition($prop); + my $sol_ss = $self->new_search_state_for($prop_seq) + ->find_solution; + die "No solution" unless $sol_ss; $self->but( proposition_sequence => $prop_seq, - search_state => $self->new_search_state_for($prop_seq) + search_state => $sol_ss, ); } diff --git a/lib/DX/ShellSession.pm b/lib/DX/ShellSession.pm index 2fb604c..fff5d1e 100644 --- a/lib/DX/ShellSession.pm +++ b/lib/DX/ShellSession.pm @@ -102,8 +102,14 @@ sub apply_predicate { introduces_names => $intro, requires_names => $need, ); - my $qstate = $self->shell_state->current_query_state; - $qstate = $qstate->with_additional_proposition($prop); + my $old_qstate = $self->shell_state->current_query_state; + my $qstate = $old_qstate->with_additional_proposition($prop); + my $old_action_count = @{ + $old_qstate->search_state->current_hypothesis->actions + }; + my @actions = @{$qstate->search_state->current_hypothesis->actions}; + push our @Result, + map [ output => $_ ], @actions[$old_action_count..$#actions]; $self->_set_shell_state( $self->shell_state->but( current_query_state => $qstate