@@ -145,7 +145,6 @@ def reset(prompt = '', encoding:)
145145 def resize
146146 return unless @resized
147147
148- Reline ::IOGate . hide_cursor
149148 @screen_size = Reline ::IOGate . get_screen_size
150149 @resized = false
151150 scroll_into_view
@@ -154,18 +153,15 @@ def resize
154153 @cursor_y = 0
155154 @rendered_screen_cache = nil
156155 render_differential
157- Reline ::IOGate . show_cursor
158156 end
159157
160158 def set_signal_handlers
161159 @old_trap = Signal . trap ( 'INT' ) {
162- Reline ::IOGate . hide_cursor
163160 clear_dialogs
164161 scrolldown = render_differential
165162 Reline ::IOGate . scroll_down scrolldown
166163 Reline ::IOGate . move_cursor_column 0
167164 @rendered_screen_cache = nil
168- Reline ::IOGate . show_cursor
169165 case @old_trap
170166 when 'DEFAULT' , 'SYSTEM_DEFAULT'
171167 raise Interrupt
@@ -488,23 +484,27 @@ def render_differential
488484 end
489485 end
490486
491- num_lines = [ [ new_lines . size , rendered_lines . size ] . max , screen_height ] . min
492- scroll_down ( num_lines - 1 - @cursor_y ) if ( num_lines - 1 - @cursor_y ) > 0
493- @cursor_y = num_lines - 1
494- num_lines . times do |i |
495- rendered_line = rendered_lines [ i ] || [ ]
496- line_to_render = new_lines [ i ] || [ ]
497- next if rendered_line == line_to_render
498-
499- Reline ::IOGate . move_cursor_down i - @cursor_y
500- @cursor_y = i
501- unless rendered_lines [ i ]
502- Reline ::IOGate . move_cursor_column 0
503- Reline ::IOGate . erase_after_cursor
487+ if new_lines != rendered_lines
488+ Reline ::IOGate . hide_cursor
489+ num_lines = [ [ new_lines . size , rendered_lines . size ] . max , screen_height ] . min
490+ scroll_down ( num_lines - 1 - @cursor_y ) if ( num_lines - 1 - @cursor_y ) > 0
491+ @cursor_y = num_lines - 1
492+ num_lines . times do |i |
493+ rendered_line = rendered_lines [ i ] || [ ]
494+ line_to_render = new_lines [ i ] || [ ]
495+ next if rendered_line == line_to_render
496+
497+ Reline ::IOGate . move_cursor_down i - @cursor_y
498+ @cursor_y = i
499+ unless rendered_lines [ i ]
500+ Reline ::IOGate . move_cursor_column 0
501+ Reline ::IOGate . erase_after_cursor
502+ end
503+ render_line_differential ( rendered_line , line_to_render )
504504 end
505- render_line_differential ( rendered_line , line_to_render )
505+ @rendered_screen_cache = new_lines
506+ Reline ::IOGate . show_cursor
506507 end
507- @rendered_screen_cache = new_lines
508508 y = editor_cursor_y - screen_scroll_top
509509 Reline ::IOGate . move_cursor_column editor_cursor_x
510510 Reline ::IOGate . move_cursor_down y - @cursor_y
@@ -525,11 +525,9 @@ def rest_height
525525 end
526526
527527 def rerender_all
528- Reline ::IOGate . hide_cursor
529528 process_insert ( force : true )
530529 handle_cleared
531530 render_differential unless @in_pasting
532- Reline ::IOGate . show_cursor
533531 end
534532
535533 def handle_cleared
@@ -546,7 +544,6 @@ def handle_cleared
546544 end
547545
548546 def rerender
549- Reline ::IOGate . hide_cursor
550547 finished = finished?
551548 handle_cleared
552549 if finished
@@ -555,7 +552,6 @@ def rerender
555552 elsif !@in_pasting
556553 render_differential
557554 end
558- Reline ::IOGate . show_cursor
559555 end
560556
561557 class DialogProcScope
0 commit comments