From 4e9f1b60f40cb36ebce3b58f97dddd365f34e908 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 --- lib/byebug/interfaces/local_interface.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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