From 3aa7ebc7db8cd833dadae1235750a72bb2a04ba9 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Fri, 26 Oct 2018 04:33:36 +0800 Subject: [PATCH] repl: fix broken input while using rb-readline Fixes #1823 (Broken upstream when rb-readline is enabled) --- lib/pry/repl.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pry/repl.rb b/lib/pry/repl.rb index f3a7b7fa..afc7864d 100644 --- a/lib/pry/repl.rb +++ b/lib/pry/repl.rb @@ -241,7 +241,11 @@ class Pry # indicators in 99% of cases. def calculate_overhang(current_prompt, original_val, indented_val) overhang = original_val.length - indented_val.length - if readline_available? && Readline.vi_editing_mode? + if readline_available? && + # rb-readline doesn't support this method: + # https://github.com/ConnorAtherton/rb-readline/issues/152 + Readline.respond_to?(:vi_editing_mode?) && + Readline.vi_editing_mode? overhang += current_prompt.length - indented_val.length end [0, overhang].max