@@ -13,7 +13,6 @@ class Reline::LineEditor
13
13
attr_accessor :prompt_proc
14
14
attr_accessor :auto_indent_proc
15
15
attr_accessor :dig_perfect_match_proc
16
- attr_writer :output
17
16
18
17
VI_MOTIONS = %i{
19
18
ed_prev_char
@@ -414,7 +413,7 @@ def render_line_differential(old_items, new_items)
414
413
# do nothing
415
414
elsif level == :blank
416
415
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 } "
418
417
else
419
418
x , w , content = new_items [ level ]
420
419
cover_begin = base_x != 0 && new_levels [ base_x - 1 ] == level
@@ -424,7 +423,7 @@ def render_line_differential(old_items, new_items)
424
423
content , pos = Reline ::Unicode . take_mbchar_range ( content , base_x - x , width , cover_begin : cover_begin , cover_end : cover_end , padding : true )
425
424
end
426
425
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 } "
428
427
end
429
428
base_x += width
430
429
end
@@ -460,19 +459,21 @@ def update_dialogs(key = nil)
460
459
end
461
460
462
461
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
468
470
end
469
- @output . puts lines . map { |l | "#{ l } \r \n " } . join
470
471
end
471
472
472
473
def print_nomultiline_prompt
473
474
Reline ::IOGate . disable_auto_linewrap ( true ) if Reline ::IOGate . win?
474
475
# 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
476
477
ensure
477
478
Reline ::IOGate . disable_auto_linewrap ( false ) if Reline ::IOGate . win?
478
479
end
@@ -503,7 +504,9 @@ def render
503
504
end
504
505
end
505
506
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
507
510
end
508
511
509
512
# Reflects lines to be rendered and new cursor position to the screen
0 commit comments