@@ -385,9 +385,11 @@ def render_line_differential(old_items, new_items)
385385 Reline ::IOGate . move_cursor_column base_x
386386 @output . write "\e [0m#{ ' ' * width } "
387387 else
388- x , w , content = new_items [ level ]
389- content = Reline ::Unicode . take_range ( content , base_x - x , width ) unless x == base_x && w == width
390- Reline ::IOGate . move_cursor_column base_x
388+ x , _w , content = new_items [ level ]
389+ cover_begin = base_x != 0 && new_levels [ base_x - 1 ] == level
390+ cover_end = new_levels [ base_x + width ] == level
391+ content , pos = Reline ::Unicode . take_mbchar_range ( content , base_x - x , width , cover_begin : cover_begin , cover_end : cover_end , padding : true )
392+ Reline ::IOGate . move_cursor_column x + pos
391393 @output . write "\e [0m#{ content } \e [0m"
392394 end
393395 base_x += width
@@ -688,13 +690,6 @@ def add_dialog_proc(name, p, context = nil)
688690
689691 DIALOG_DEFAULT_HEIGHT = 20
690692
691- private def padding_space_with_escape_sequences ( str , width )
692- padding_width = width - calculate_width ( str , true )
693- # padding_width should be only positive value. But macOS and Alacritty returns negative value.
694- padding_width = 0 if padding_width < 0
695- str + ( ' ' * padding_width )
696- end
697-
698693 private def dialog_range ( dialog , dialog_y )
699694 x_range = dialog . column ...dialog . column + dialog . width
700695 y_range = dialog_y + dialog . vertical_offset ...dialog_y + dialog . vertical_offset + dialog . contents . size
@@ -768,7 +763,7 @@ def add_dialog_proc(name, p, context = nil)
768763 dialog . contents = contents . map . with_index do |item , i |
769764 line_sgr = i == pointer ? enhanced_sgr : default_sgr
770765 str_width = dialog . width - ( scrollbar_pos . nil? ? 0 : @block_elem_width )
771- str = padding_space_with_escape_sequences ( Reline ::Unicode . take_range ( item , 0 , str_width ) , str_width )
766+ str , = Reline ::Unicode . take_mbchar_range ( item , 0 , str_width , padding : true )
772767 colored_content = "#{ line_sgr } #{ str } "
773768 if scrollbar_pos
774769 if scrollbar_pos <= ( i * 2 ) and ( i * 2 + 1 ) < ( scrollbar_pos + bar_height )
0 commit comments