Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bracketed paste and scrolling bug #801

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ def readline(prompt = '', add_hist = false)
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
Expand All @@ -350,14 +349,14 @@ def readline(prompt = '', add_hist = false)
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
}
if line_editor.finished?
line_editor.render_finished
break
else
line_editor.set_pasting_state(io_gate.in_pasting?)
line_editor.rerender
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def render
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
Expand Down
8 changes: 8 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,14 @@ def test_bracketed_paste
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

Expand Down
Loading