diff options
author | tomoya ishida <tomoyapenguin@gmail.com> | 2025-01-05 13:57:19 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2025-01-05 04:57:23 +0000 |
commit | 9a15672614c772d80ecd43d41653399b0ed98d89 (patch) | |
tree | 074fee68971c41792d3eec831fadba21ad4ed85b | |
parent | dfc9e978fba886d9a9175534551b1fc7b4d22abd (diff) |
[ruby/reline] Fix bracketed paste and scrolling bug
(https://github.com/ruby/reline/pull/801)
* Fix set_pasting_state bug with bracketed paste
* Fix rendered cursor_y caching in case of rendering the screen without scroll_into_view
https://github.com/ruby/reline/commit/c5d5c444df
-rw-r--r-- | lib/reline.rb | 3 | ||||
-rw-r--r-- | lib/reline/line_editor.rb | 1 | ||||
-rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/reline.rb b/lib/reline.rb index 52e1e399c3..5d1fcbf8e8 100644 --- a/lib/reline.rb +++ b/lib/reline.rb @@ -341,7 +341,6 @@ module Reline line_editor.set_signal_handlers loop do read_io(config.keyseq_timeout) { |inputs| - line_editor.set_pasting_state(io_gate.in_pasting?) inputs.each do |key| case key.method_symbol when :bracketed_paste_start @@ -350,6 +349,7 @@ module Reline when :quoted_insert, :ed_quoted_insert key = Reline::Key.new(io_gate.read_single_char(config.keyseq_timeout), :insert_raw_char) end + line_editor.set_pasting_state(io_gate.in_pasting?) line_editor.update(key) end } @@ -357,7 +357,6 @@ module Reline line_editor.render_finished break else - line_editor.set_pasting_state(io_gate.in_pasting?) line_editor.rerender end end diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index 0895234aea..aa4c7facdc 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -542,6 +542,7 @@ class Reline::LineEditor Reline::IOGate.show_cursor end Reline::IOGate.move_cursor_column new_cursor_x + new_cursor_y = new_cursor_y.clamp(0, screen_height - 1) Reline::IOGate.move_cursor_down new_cursor_y - cursor_y @rendered_screen.cursor_y = new_cursor_y ensure diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 2952d3bfc8..782ad71eb9 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -550,6 +550,14 @@ begin prompt> 3 prompt> end EOC + write("\e[200~.tap do\r\t4\r\t5\rend\e[201~") + assert_screen(<<~EOC) + prompt> 3 + prompt> end.tap do + prompt> 4 + prompt> 5 + prompt> end + EOC close end |