Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the byebug line # to make the output clickable #553

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

* [#553](https://github.com/deivid-rodriguez/byebug/pull/553): Shows the line number in the byebug statement so that supporting IDEs can take cursor to the debug point instead of the head of the file ([@senhalil]).

### Fixed

* [#562](https://github.com/deivid-rodriguez/byebug/pull/562): post mortem mode landing in the wrong line when coming from an exception inside a `Kernel.load` call.
Expand Down
2 changes: 1 addition & 1 deletion lib/byebug/commands/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def move(line, size, direction = "+")
# @param max [Integer] Upper bound
#
def display_lines(min, max)
puts "\n[#{min}, #{max}] in #{frame.file}"
puts "\n[#{min}, #{max}] in #{frame.file}:#{frame.line}"

puts source_file_formatter.lines(min, max).join
end
Expand Down
32 changes: 16 additions & 16 deletions test/commands/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_lists_source_code_lines
enter "list"
debug_code(program)

check_output_includes "[12, 14] in #{example_path}"
check_output_includes "[12, 14] in #{example_path}:13"
end
end

Expand All @@ -42,7 +42,7 @@ def test_listsize_is_not_set_if_parameter_is_not_an_integer
enter "set listsize 5.0", "list"
debug_code(program)

check_output_doesnt_include "[11, 15] in #{example_path}"
check_output_doesnt_include "[11, 15] in #{example_path}:13"
end
end

Expand All @@ -51,7 +51,7 @@ def test_does_not_list_before_the_beginning_of_file
enter "cont 7", "list"
debug_code(program)

check_output_includes "[1, 15] in #{example_path}"
check_output_includes "[1, 15] in #{example_path}:7"
end
end

Expand All @@ -60,7 +60,7 @@ def test_does_not_list_after_the_end_of_file
enter "list"
debug_code(program)

check_output_includes "[4, 16] in #{example_path}"
check_output_includes "[4, 16] in #{example_path}:13"
end
end

Expand All @@ -69,7 +69,7 @@ def test_lists_the_whole_file_if_number_of_lines_is_smaller_than_listsize
enter "list"
debug_code(program)

check_output_includes "[1, 16] in #{example_path}"
check_output_includes "[1, 16] in #{example_path}:13"
end
end

Expand All @@ -78,7 +78,7 @@ def test_lists_forwards_after_the_second_call_to_list
enter "cont 7", "list", "list"
debug_code(program)

check_output_includes "[9, 11] in #{example_path}"
check_output_includes "[9, 11] in #{example_path}:7"
end
end

Expand All @@ -87,7 +87,7 @@ def test_lists_surrounding_lines_after_the_first_call_to_list_minus
enter "list-"
debug_code(program)

check_output_includes "[12, 14] in #{example_path}"
check_output_includes "[12, 14] in #{example_path}:13"
end
end

Expand All @@ -96,7 +96,7 @@ def test_lists_backwards_after_the_second_call_to_list_minus
enter "list-", "list-"
debug_code(program)

check_output_includes "[9, 11] in #{example_path}"
check_output_includes "[9, 11] in #{example_path}:13"
end
end

Expand All @@ -105,7 +105,7 @@ def test_lists_backwards_from_end_of_file
enter "list 14-16", "list -"
debug_code(program)

check_output_includes "[11, 13] in #{example_path}"
check_output_includes "[11, 13] in #{example_path}:13"
end
end

Expand All @@ -114,46 +114,46 @@ def test_lists_surrounding_lines_when_list_equals_is_called
enter "list ="
debug_code(program)

check_output_includes "[12, 14] in #{example_path}"
check_output_includes "[12, 14] in #{example_path}:13"
end
end

def test_lists_specific_range_when_requested_in_hyphen_format
enter "list 6-8"
debug_code(program)

check_output_includes "[6, 8] in #{example_path}"
check_output_includes "[6, 8] in #{example_path}:13"
end

def test_lists_specific_range_when_requested_in_comma_format
enter "list 6,8"
debug_code(program)

check_output_includes "[6, 8] in #{example_path}"
check_output_includes "[6, 8] in #{example_path}:13"
end

def test_lists_nothing_if_unexistent_range_is_specified
enter "list 20,25"
debug_code(program)

check_error_includes '"List" argument "20" needs to be at most 16'
check_output_doesnt_include "[20, 25] in #{example_path}"
check_output_doesnt_include "[20, 25] in #{example_path}:13"
end

def test_lists_nothing_if_invalid_range_is_specified
enter "list 5,4"
debug_code(program)

check_error_includes "Invalid line range"
check_output_doesnt_include "[5, 4] in #{example_path}"
check_output_doesnt_include "[5, 4] in #{example_path}:13"
end

def test_list_proper_lines_when_range_around_specific_line_with_hyphen
with_setting :listsize, 3 do
enter "list 4-"
debug_code(program)

check_output_includes "[3, 5] in #{example_path}"
check_output_includes "[3, 5] in #{example_path}:13"
end
end

Expand All @@ -162,7 +162,7 @@ def test_list_proper_lines_when_range_around_specific_line_with_comma
enter "list 4,"
debug_code(program)

check_output_includes "[3, 5] in #{example_path}"
check_output_includes "[3, 5] in #{example_path}:13"
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/processors/command_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def program
def test_autolists_lists_source_before_stopping
debug_code(program)

check_output_includes "[5, 14] in #{example_path}"
check_output_includes "[5, 14] in #{example_path}:11"
end

def test_shows_error_when_current_source_location_is_unknown
Expand Down