diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2018-11-03 14:11:48 +0800 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2018-11-03 14:13:39 +0800 |
commit | f96bca950e64b4d332babeb4bd2cd02badc2967d (patch) | |
tree | 5b807b36318a444c55fc5b6b8e6bb36315c38f57 | |
parent | 312ab5aba414838b7dc3c44e84817ba7fb3009c5 (diff) | |
download | pry-f96bca950e64b4d332babeb4bd2cd02badc2967d.tar.gz |
repl: calculate JRuby overhang (or rather not)
Fixes #1840
(NotImplementedError: vi_editing_mode?() function is unimplemented on this
machine)
-rw-r--r-- | lib/pry/repl.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/pry/repl.rb b/lib/pry/repl.rb index ff96c2d2..0b4d7480 100644 --- a/lib/pry/repl.rb +++ b/lib/pry/repl.rb @@ -241,12 +241,19 @@ 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? && - # 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 + + if readline_available? && Readline.respond_to?(:vi_editing_mode?) + begin + # rb-readline doesn't support this method: + # https://github.com/ConnorAtherton/rb-readline/issues/152 + if Readline.vi_editing_mode? + overhang += current_prompt.length - indented_val.length + end + rescue NotImplementedError + # VI editing mode is unsupported on JRuby. + # https://github.com/pry/pry/issues/1840 + nil + end end [0, overhang].max end |