1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

repl: calculate JRuby overhang (or rather not)

Fixes #1840
(NotImplementedError: vi_editing_mode?() function is unimplemented on this
machine)
This commit is contained in:
Kyrylo Silin 2018-11-03 14:11:48 +08:00
parent 312ab5aba4
commit f96bca950e

View file

@ -241,13 +241,20 @@ 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? &&
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
Readline.respond_to?(:vi_editing_mode?) &&
Readline.vi_editing_mode?
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
end