Skip to content

Commit

Permalink
Fix crash on TAB under ruby 2.7
Browse files Browse the repository at this point in the history
When IRB from ruby 2.7 is loaded, it installs a Readline completion proc
that assumes IRB is running (and crashes otherwise). Workaround this by
clearing the Readline completion when using it directly.

Fixes #654
  • Loading branch information
terceiro authored and deivid-rodriguez committed Apr 14, 2020
1 parent 5fa9a39 commit c6fdcfc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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
11 changes: 10 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_irb_completion { Readline.readline(prompt) || EOF_ALIAS } }
end

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

# Disables the Readline completion proc installed by IRB on ruby2.7
def without_irb_completion
orig_completion = Readline.completion_proc
Readline.completion_proc = nil
yield
ensure
Readline.completion_proc = orig_completion
end
end
end

0 comments on commit c6fdcfc

Please sign in to comment.