diff --git a/src/prompt_toolkit/layout/containers.py b/src/prompt_toolkit/layout/containers.py index 19c134a42..8f2b9896a 100644 --- a/src/prompt_toolkit/layout/containers.py +++ b/src/prompt_toolkit/layout/containers.py @@ -2040,8 +2040,8 @@ def find_next_wrap( except IndexError: return sys.maxsize, 0, [] - char_pos -= fragment_list_len(line[:fragment]) - line_part = [(style0, text0[char_pos:]), *line[fragment + 1 :]] + frag_char_pos = char_pos - fragment_list_len(line[:fragment]) + line_part = [(style0, text0[frag_char_pos:]), *line[fragment + 1 :]] line_width = [fragment_list_width([frag]) for frag in line_part] line_width = [fragment_list_width([frag]) for frag in line_part]