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

Fix crash on TAB under ruby 2.7 #657

Merged
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

* [#657](https://github.com/deivid-rodriguez/byebug/pull/657): crash when hitting \<TAB\> due to IRB completion mechanism included in the default ruby 2.7 version of the `irb` gem ([@terceiro]).

## [11.1.1] - 2020-01-24

### Fixed
Expand Down Expand Up @@ -911,6 +915,7 @@
[@sethk]: https://github.com/sethk
[@shuky19]: https://github.com/shuky19
[@tacnoman]: https://github.com/tacnoman
[@terceiro]: https://github.com/terceiro
[@tzmfreedom]: https://github.com/tzmfreedom
[@wallace]: https://github.com/wallace
[@windwiny]: https://github.com/windwiny
Expand Down
21 changes: 20 additions & 1 deletion lib/byebug/interfaces/local_interface.rb
Expand Up @@ -21,7 +21,7 @@ def initialize
# @param prompt Prompt to be displayed.
#
def readline(prompt)
with_repl_like_sigint { Readline.readline(prompt) || EOF_ALIAS }
with_repl_like_sigint { without_readline_completion { Readline.readline(prompt) || EOF_ALIAS } }
end

#
Expand All @@ -40,5 +40,24 @@ def with_repl_like_sigint
ensure
trap("INT", orig_handler)
end

#
# Disable any Readline completion procs.
#
# Other gems, for example, IRB could've installed completion procs that are
# dependent on them being loaded. Disable those while byebug is the REPL
# making use of Readline.
#
def without_readline_completion
orig_completion = Readline.completion_proc
return yield unless orig_completion

begin
Readline.completion_proc = nil
yield
ensure
Readline.completion_proc = orig_completion
end
end
end
end
9 changes: 9 additions & 0 deletions test/runner_against_valid_program_test.rb
Expand Up @@ -118,6 +118,15 @@ def test_run_with_debug_flag
assert_match(/Debug flag is true/, stdout)
end

def test_run_and_press_tab_doesnt_make_byebug_crash
stdout = run_byebug(
example_path,
input: "\tputs 'Reached here'"
)

assert_match(/Reached here/, stdout)
end

def test_run_stops_at_the_first_line_by_default
stdout = run_byebug(example_path)

Expand Down