Skip to content

Commit

Permalink
Introduce continue! to continue till the end (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored Jan 6, 2019
1 parent 1a44676 commit 592c858
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

* [#524](https://github.com/deivid-rodriguez/byebug/pull/524): `continue!` (or `continue unconditionally`) to continue until the end of the program regardless of the currently enabled breakpoints ([@tacnomann]).

### Fixed

* [#527](https://github.com/deivid-rodriguez/byebug/pull/527): `break` help text to clarify placeholders from literals.
Expand Down Expand Up @@ -872,6 +876,7 @@
[@Olgagr]: https://github.com/Olgagr
[@sethk]: https://github.com/sethk
[@shuky19]: https://github.com/shuky19
[@tacnoman]: https://github.com/tacnoman
[@tzmfreedom]: https://github.com/tzmfreedom
[@wallace]: https://github.com/wallace
[@windwiny]: https://github.com/windwiny
Expand Down
27 changes: 23 additions & 4 deletions lib/byebug/commands/continue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ class ContinueCommand < Command
include Helpers::ParseHelper

def self.regexp
/^\s* c(?:ont(?:inue)?)? (?:\s+(\S+))? \s*$/x
/^\s* c(?:ont(?:inue)?)? (?:(!|\s+unconditionally|\s+\S+))? \s*$/x
end

def self.description
<<-DESCRIPTION
c[ont[inue]][ <line_number>]
#{short_description}
Normally the program stops at the next breakpoint. However, if the
parameter "unconditionally" is given or the command is suffixed with
"!", the program will run until the end regardless of any enabled
breakpoints.
DESCRIPTION
end

Expand All @@ -30,8 +35,8 @@ def self.short_description
end

def execute
if @match[1]
num, err = get_int(@match[1], "Continue", 0, nil)
if until_line?
num, err = get_int(modifier, "Continue", 0, nil)
return errmsg(err) unless num

filename = File.expand_path(frame.file)
Expand All @@ -42,7 +47,21 @@ def execute

processor.proceed!

Byebug.stop if Byebug.stoppable?
Byebug.stop if unconditionally? || Byebug.stoppable?
end

private

def until_line?
@match[1] && !["!", "unconditionally"].include?(modifier)
end

def unconditionally?
@match[1] && ["!", "unconditionally"].include?(modifier)
end

def modifier
@match[1].lstrip
end
end
end
12 changes: 12 additions & 0 deletions test/commands/continue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ def test_continues_until_the_end_if_no_line_specified_and_no_breakpoints
debug_code(program) { assert_program_finished }
end

def test_continues_until_the_end_if_used_with_bang
enter "break 14", "continue!"

debug_code(program) { assert_program_finished }
end

def test_continues_until_the_end_if_used_with_unconditionally
enter "break 14", "continue unconditionally"

debug_code(program) { assert_program_finished }
end

def test_stops_byebug_after_continue
enter "continue"

Expand Down

0 comments on commit 592c858

Please sign in to comment.