Browse files

Better handling of END on quit; fixes #13.

Now, when you quit and there are END blocks queued up, you are asked
if you wish to run them. Doing so will return the prompt to a saner
state if you happened to be in an exceptional state.
  • Loading branch information...
1 parent fde4726 commit 7d0127e02015546e16992259ee838cff1e0cefea @jnthn committed Aug 22, 2013
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/Debugger/UI/CommandLine.pm
View
16 lib/Debugger/UI/CommandLine.pm
@@ -559,6 +559,22 @@ my class DebugState {
say self.usage()
}
when 'q' | 'quit' {
+ my \ENDS := nqp::getcurhllsym('@END_PHASERS');
+ if nqp::elems(ENDS) {
+ my $end_prompt = colored('- ', self.prompt_color()) ~
+ 'Run END blocks (y/N)? ';
+ if prompt($end_prompt) ~~ /:i ^ y/ {
+ # Make sure we return to a sane state first.
+ $run_mode = Step;
+ $dying = False;
+ $in_prompt = False;
+ $cur_ex = Nil;
+ }
+ else {
+ # Remove end blocks so we don't run them on exit.
+ nqp::bindcurhllsym('@END_PHASERS', nqp::list());
+ }
+ }
exit(0);
}
default {

0 comments on commit 7d0127e

Please sign in to comment.