From 092a4b145b32a02ee69d38189f9d3cd9f95eaa0a Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 30 Mar 2020 10:41:22 -0300 Subject: [PATCH] Fix crash on TAB under ruby 2.7 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 --- CHANGELOG.md | 5 +++++ lib/byebug/interfaces/local_interface.rb | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1d94e7b..e5889dc56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +* [#657](https://github.com/deivid-rodriguez/byebug/pull/657): crash when hitting \ 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 @@ -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 diff --git a/lib/byebug/interfaces/local_interface.rb b/lib/byebug/interfaces/local_interface.rb index 65b7d67c8..c9262f21e 100644 --- a/lib/byebug/interfaces/local_interface.rb +++ b/lib/byebug/interfaces/local_interface.rb @@ -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 # @@ -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