diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index a9fb959ce4..d2c32898b3 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -112,10 +112,11 @@ class Reline::ANSI @@input.raw do |stdin| @@output << "\e[6n" @@output.flush - while (c = stdin.getc) != 'R' - res << c if c + while (c = stdin.getc) + res << c + m = res.match(/\e\[(?\d+);(?\d+)R/) + break if m end - m = res.match(/\e\[(?\d+);(?\d+)/) (m.pre_match + m.post_match).chars.reverse_each do |ch| stdin.ungetc ch end