diff --git a/lib/reline/ansi.rb b/lib/reline/ansi.rb index 36ac7257e8..10f112964c 100644 --- a/lib/reline/ansi.rb +++ b/lib/reline/ansi.rb @@ -112,10 +112,11 @@ def self.cursor_pos @@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