Skip to content

Commit

Permalink
Change rendered_screen.lines to non-nil (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored Mar 20, 2024
1 parent 3fa3762 commit 9685db5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def resize
scroll_into_view
Reline::IOGate.move_cursor_up @rendered_screen.cursor_y
@rendered_screen.base_y = Reline::IOGate.cursor_pos.y
@rendered_screen.lines = nil
@rendered_screen.lines = []
@rendered_screen.cursor_y = 0
render_differential
end
Expand All @@ -164,7 +164,7 @@ def set_signal_handlers
scrolldown = render_differential
Reline::IOGate.scroll_down scrolldown
Reline::IOGate.move_cursor_column 0
@rendered_screen.lines = nil
@rendered_screen.lines = []
@rendered_screen.cursor_y = 0
case @old_trap
when 'DEFAULT', 'SYSTEM_DEFAULT'
Expand Down Expand Up @@ -217,7 +217,7 @@ def reset_variables(prompt = '', encoding:)
@dialogs = []
@resized = false
@cache = {}
@rendered_screen = RenderedScreen.new(base_y: 0, lines: nil, cursor_y: 0)
@rendered_screen = RenderedScreen.new(base_y: 0, lines: [], cursor_y: 0)
reset_line
end

Expand Down Expand Up @@ -421,7 +421,7 @@ def clear_rendered_lines
Reline::IOGate.move_cursor_up @rendered_screen.cursor_y
Reline::IOGate.move_cursor_column 0

num_lines = @rendered_screen.lines&.size
num_lines = @rendered_screen.lines.size
return unless num_lines && num_lines >= 1

Reline::IOGate.move_cursor_down num_lines - 1
Expand All @@ -430,7 +430,7 @@ def clear_rendered_lines
Reline::IOGate.move_cursor_up 1
end
Reline::IOGate.erase_after_cursor
@rendered_screen.lines = nil
@rendered_screen.lines = []
@rendered_screen.cursor_y = 0
end

Expand All @@ -455,7 +455,7 @@ def print_nomultiline_prompt(prompt)
def render_differential
wrapped_cursor_x, wrapped_cursor_y = wrapped_cursor_position

rendered_lines = @rendered_screen.lines || []
rendered_lines = @rendered_screen.lines
new_lines = wrapped_lines.flatten[screen_scroll_top, screen_height].map do |l|
[[0, Reline::Unicode.calculate_width(l, true), l]]
end
Expand Down Expand Up @@ -528,7 +528,7 @@ def handle_cleared
@cleared = false
Reline::IOGate.clear_screen
@screen_size = Reline::IOGate.get_screen_size
@rendered_screen.lines = nil
@rendered_screen.lines = []
@rendered_screen.base_y = 0
@rendered_screen.cursor_y = 0
end
Expand Down

0 comments on commit 9685db5

Please sign in to comment.