@@ -1944,7 +1944,7 @@ def render_margin(m: Margin, width: int) -> UIContent:
19441944 def _whitespace_wrap_finder (
19451945 self ,
19461946 ui_content : UIContent ,
1947- sep : str | re .Pattern = r"\s" ,
1947+ sep : str | re .Pattern [ str ] = r"\s" ,
19481948 split : str = "remove" ,
19491949 continuation : StyleAndTextTuples = [],
19501950 ) -> WrapFinderCallable :
@@ -2024,15 +2024,22 @@ def _copy_body(
20242024 # Maps (row, col) from the input to (y, x) screen coordinates.
20252025 rowcol_to_yx : dict [tuple [int , int ], tuple [int , int ]] = {}
20262026
2027- def find_next_wrap (remaining_width , is_input , lineno , fragment = 0 , char_pos = 0 ):
2027+ def find_next_wrap (
2028+ remaining_width : int ,
2029+ is_input : bool ,
2030+ lineno : int ,
2031+ fragment : int = 0 ,
2032+ char_pos : int = 0 ,
2033+ ) -> tuple [int , int , AnyFormattedText ]:
20282034 if not wrap_lines :
20292035 return sys .maxsize , 0 , []
20302036
20312037 line = ui_content .get_line (lineno )
20322038 style0 , text0 , * more = line [fragment ]
2033- char_pos - fragment_list_len (line [:fragment ])
2034- line_part = [(style0 , text0 [char_pos :], * more ), * line [fragment + 1 :]]
2035- line_width = [fragment_list_width ([fragment ]) for fragment in line_part ]
2039+ char_pos -= fragment_list_len (line [:fragment ])
2040+ line_part = [(style0 , text0 [char_pos :]), * line [fragment + 1 :]]
2041+ line_width = [fragment_list_width ([frag ]) for frag in line_part ]
2042+ line_width = [fragment_list_width ([frag ]) for frag in line_part ]
20362043
20372044 if sum (line_width ) <= remaining_width :
20382045 return sys .maxsize , 0 , []
@@ -2054,10 +2061,15 @@ def find_next_wrap(remaining_width, is_input, lineno, fragment=0, char_pos=0):
20542061 remaining_width -= char_width
20552062 max_wrap_pos += 1
20562063
2057- if is_input and wrap_finder :
2058- return wrap_finder (lineno , min_wrap_pos , max_wrap_pos )
2059- else :
2060- return max_wrap_pos , 0 , []
2064+ return (
2065+ wrap_finder (lineno , min_wrap_pos , max_wrap_pos )
2066+ if is_input and wrap_finder
2067+ else None
2068+ ) or (
2069+ max_wrap_pos ,
2070+ 0 ,
2071+ [],
2072+ )
20612073
20622074 def copy_line (
20632075 line : StyleAndTextTuples ,
0 commit comments