Skip to content

Commit

Permalink
Fix render_full_content and clearing screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Nov 22, 2023
1 parent e861087 commit 90062f0
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,29 @@ def update_dialogs(key = nil)
end
end

def clear_rendered_lines
Reline::IOGate.move_cursor_up @cursor_y
Reline::IOGate.move_cursor_column 0

num_lines = @rendered_screen_cache&.size
return unless num_lines && num_lines >= 1

Reline::IOGate.move_cursor_down num_lines - 1
(num_lines - 1).times do
Reline::IOGate.erase_after_cursor
Reline::IOGate.move_cursor_up 1
end
Reline::IOGate.erase_after_cursor
@rendered_screen_cache = nil
end

def render_full_content
@output.puts wrapped_lines.flatten.map { |l| "#{l}\r\n" }.join
lines = @buffer_of_lines.size.times.map do |i|
line = prompt_list[i] + modified_lines[i]
wrapped_lines, = split_by_width(line, screen_width)
wrapped_lines.last.empty? ? "#{line} " : line
end
@output.puts lines.map { |l| "#{l}\r\n" }.join
end

def print_nomultiline_prompt(prompt)
Expand Down Expand Up @@ -510,10 +531,7 @@ def rerender
finished = finished?
handle_cleared
if finished
clear_dialogs
render_differential
Reline::IOGate.move_cursor_up @cursor_y
Reline::IOGate.move_cursor_column 0
clear_rendered_lines
render_full_content
elsif !@in_pasting
render_differential
Expand Down

0 comments on commit 90062f0

Please sign in to comment.