Skip to content

Commit

Permalink
Restore previous autolist value after skip
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Mar 11, 2019
1 parent 8612245 commit dbc14f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 12 additions & 2 deletions lib/byebug/commands/skip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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,7 +51,7 @@ def self.short_description

def initialize_attributes
self.class.always_run = 2
ListCommand.always_run = 0
self.class.setup_autolist(0)
self.class.file_path = frame.file
self.class.file_line = frame.line
end
Expand All @@ -52,7 +62,7 @@ def keep_execution

def reset_attributes
self.class.always_run = 0
ListCommand.always_run = 1
self.class.restore_autolist
end

def auto_run
Expand Down
15 changes: 13 additions & 2 deletions test/commands/skip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def program
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 @@ -50,5 +51,15 @@ def test_does_not_list_code_for_intermediate_breakpoints
check_output_includes "=> 10: i *= new_number"
check_output_doesnt_include "=> 10: i *= new_number", "=> 10: i *= new_number"
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 dbc14f5

Please sign in to comment.