@@ -1944,7 +1944,7 @@ def render_margin(m: Margin, width: int) -> UIContent:
1944
1944
def _whitespace_wrap_finder (
1945
1945
self ,
1946
1946
ui_content : UIContent ,
1947
- sep : str | re .Pattern = r"\s" ,
1947
+ sep : str | re .Pattern [ str ] = r"\s" ,
1948
1948
split : str = "remove" ,
1949
1949
continuation : StyleAndTextTuples = [],
1950
1950
) -> WrapFinderCallable :
@@ -2024,15 +2024,22 @@ def _copy_body(
2024
2024
# Maps (row, col) from the input to (y, x) screen coordinates.
2025
2025
rowcol_to_yx : dict [tuple [int , int ], tuple [int , int ]] = {}
2026
2026
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 ]:
2028
2034
if not wrap_lines :
2029
2035
return sys .maxsize , 0 , []
2030
2036
2031
2037
line = ui_content .get_line (lineno )
2032
2038
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 ]
2036
2043
2037
2044
if sum (line_width ) <= remaining_width :
2038
2045
return sys .maxsize , 0 , []
@@ -2054,10 +2061,15 @@ def find_next_wrap(remaining_width, is_input, lineno, fragment=0, char_pos=0):
2054
2061
remaining_width -= char_width
2055
2062
max_wrap_pos += 1
2056
2063
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
+ )
2061
2073
2062
2074
def copy_line (
2063
2075
line : StyleAndTextTuples ,
0 commit comments