Skip to content

Commit

Permalink
Merge pull request #545 from deivid-rodriguez/fix_skip_output
Browse files Browse the repository at this point in the history
Fix `skip` output
  • Loading branch information
deivid-rodriguez committed Mar 11, 2019
2 parents f18a730 + c8f58c3 commit 5811e4f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed

* [#546](https://github.com/deivid-rodriguez/byebug/pull/546): `continue!` to ignore further `byebug` calls.
* [#545](https://github.com/deivid-rodriguez/byebug/pull/545): `skip` autolisting code for intermediate skipped breakpoints.

## [11.0.0] - 2019-02-15

Expand Down
14 changes: 14 additions & 0 deletions lib/byebug/commands/skip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SkipCommand < Command

class << self
attr_writer :file_line, :file_path
attr_reader :previous_autolist

def file_line
@file_line ||= 0
Expand All @@ -21,6 +22,16 @@ def file_line
def file_path
@file_path ||= ""
end

def setup_autolist(value)
@previous_autolist = ListCommand.always_run
ListCommand.always_run = value
end

def restore_autolist
ListCommand.always_run = @previous_autolist
@previous_autolist = nil
end
end

def self.regexp
Expand All @@ -41,6 +52,7 @@ def self.short_description

def initialize_attributes
self.class.always_run = 2
self.class.setup_autolist(0)
self.class.file_path = frame.file
self.class.file_line = frame.line
end
Expand All @@ -51,6 +63,8 @@ def keep_execution

def reset_attributes
self.class.always_run = 0
ListCommand.new(processor).execute if self.class.previous_autolist == 1
self.class.restore_autolist
end

def auto_run
Expand Down
29 changes: 25 additions & 4 deletions test/commands/skip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ def program
6: def factor(num)
7: i = 1
8: num.times do |new_number|
9: i *= new_number
10: byebug
9: byebug
10: i *= new_number
11: end
12: end
13: end
14: c = 5
15:
16: result = #{example_class}.new.factor(c)
17: "Result is: " + result.to_s
18: end
17: sleep 0
18: "Result is: " + result.to_s
19: end
RUBY
end

Expand All @@ -41,5 +42,25 @@ def test_works_in_abbreviated_mode_too

debug_code(program) { assert_location example_path, 17 }
end

def test_does_not_list_code_for_intermediate_breakpoints
enter "break 17", "skip"

debug_code(program)

check_output_includes "=> 10: i *= new_number"
check_output_doesnt_include "=> 10: i *= new_number", "=> 10: i *= new_number"
check_output_includes "=> 17: sleep 0"
end

def test_restores_previous_autolisting_after_skip
with_setting :autolist, false do
enter "break 17", "skip", "continue 18"

debug_code(program)

check_output_doesnt_include '=> 18: "Result is: " + result.to_s'
end
end
end
end

0 comments on commit 5811e4f

Please sign in to comment.