@@ -13,7 +13,6 @@ class Reline::LineEditor
1313 attr_accessor :prompt_proc
1414 attr_accessor :auto_indent_proc
1515 attr_accessor :dig_perfect_match_proc
16- attr_writer :output
1716
1817 VI_MOTIONS = %i{
1918 ed_prev_char
@@ -414,7 +413,7 @@ def render_line_differential(old_items, new_items)
414413 # do nothing
415414 elsif level == :blank
416415 Reline ::IOGate . move_cursor_column base_x
417- @output . write "#{ Reline ::IOGate . reset_color_sequence } #{ ' ' * width } "
416+ Reline :: IOGate . write "#{ Reline ::IOGate . reset_color_sequence } #{ ' ' * width } "
418417 else
419418 x , w , content = new_items [ level ]
420419 cover_begin = base_x != 0 && new_levels [ base_x - 1 ] == level
@@ -424,7 +423,7 @@ def render_line_differential(old_items, new_items)
424423 content , pos = Reline ::Unicode . take_mbchar_range ( content , base_x - x , width , cover_begin : cover_begin , cover_end : cover_end , padding : true )
425424 end
426425 Reline ::IOGate . move_cursor_column x + pos
427- @output . write "#{ Reline ::IOGate . reset_color_sequence } #{ content } #{ Reline ::IOGate . reset_color_sequence } "
426+ Reline :: IOGate . write "#{ Reline ::IOGate . reset_color_sequence } #{ content } #{ Reline ::IOGate . reset_color_sequence } "
428427 end
429428 base_x += width
430429 end
@@ -460,19 +459,21 @@ def update_dialogs(key = nil)
460459 end
461460
462461 def render_finished
463- render_differential ( [ ] , 0 , 0 )
464- lines = @buffer_of_lines . size . times . map do |i |
465- line = Reline ::Unicode . strip_non_printing_start_end ( prompt_list [ i ] ) + modified_lines [ i ]
466- wrapped_lines = split_line_by_width ( line , screen_width )
467- wrapped_lines . last . empty? ? "#{ line } " : line
462+ Reline ::IOGate . buffered_output do
463+ render_differential ( [ ] , 0 , 0 )
464+ lines = @buffer_of_lines . size . times . map do |i |
465+ line = Reline ::Unicode . strip_non_printing_start_end ( prompt_list [ i ] ) + modified_lines [ i ]
466+ wrapped_lines = split_line_by_width ( line , screen_width )
467+ wrapped_lines . last . empty? ? "#{ line } " : line
468+ end
469+ Reline ::IOGate . write lines . map { |l | "#{ l } \r \n " } . join
468470 end
469- @output . puts lines . map { |l | "#{ l } \r \n " } . join
470471 end
471472
472473 def print_nomultiline_prompt
473474 Reline ::IOGate . disable_auto_linewrap ( true ) if Reline ::IOGate . win?
474475 # Readline's test `TestRelineAsReadline#test_readline` requires first output to be prompt, not cursor reset escape sequence.
475- @output . write Reline ::Unicode . strip_non_printing_start_end ( @prompt ) if @prompt && !@is_multiline
476+ Reline :: IOGate . write Reline ::Unicode . strip_non_printing_start_end ( @prompt ) if @prompt && !@is_multiline
476477 ensure
477478 Reline ::IOGate . disable_auto_linewrap ( false ) if Reline ::IOGate . win?
478479 end
@@ -503,7 +504,9 @@ def render
503504 end
504505 end
505506
506- render_differential new_lines , wrapped_cursor_x , wrapped_cursor_y - screen_scroll_top
507+ Reline ::IOGate . buffered_output do
508+ render_differential new_lines , wrapped_cursor_x , wrapped_cursor_y - screen_scroll_top
509+ end
507510 end
508511
509512 # Reflects lines to be rendered and new cursor position to the screen
0 commit comments