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 committed Mar 30, 2020
1 parent 6cac727 commit 07d4e9b
Showing 1 changed file with 10 additions and 1 deletion.
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 07d4e9b

Please sign in to comment.