diff --git a/jruby/lib/io/console/common.rb b/jruby/lib/io/console/common.rb index 9252bd9..b75a39a 100644 --- a/jruby/lib/io/console/common.rb +++ b/jruby/lib/io/console/common.rb @@ -108,6 +108,7 @@ def cursor end end + return nil unless b && result.length == 2 result.map(&:pred) end end diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 48743fc..8b80754 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -456,6 +456,8 @@ def test_cursor_position con.cursor_right(4); con.puts con.cursor_left(2); con.puts con.cursor_up(1); con.puts + p con.cursor + p con.cursor end; assert_equal("\e[6n", r.readpartial(5)) w.print("\e[12;34R"); w.flush @@ -464,6 +466,14 @@ def test_cursor_position assert_equal("\e[4C", r.gets.chomp) assert_equal("\e[2D", r.gets.chomp) assert_equal("\e[1A", r.gets.chomp) + + assert_equal("\e[6n", r.readpartial(5)) + w.print("\e[12R"); w.flush + assert_equal("nil", r.gets.chomp) + + assert_equal("\e[6n", r.readpartial(5)) + w.print("\e[12;34;56R"); w.flush + assert_equal("nil", r.gets.chomp) end end