Skip to content

Commit 6e402e2

Browse files
committed
Add strings that cause wcwidth to return -1 to assertion message
1 parent 2bb6265 commit 6e402e2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,13 +1579,13 @@ def move_screen_up(current_line_start_row):
15791579
assert cursor_row >= 0 and cursor_column >= 0, (
15801580
cursor_row,
15811581
cursor_column,
1582+
self.current_stdouterr_line,
1583+
self.stdin.current_line,
15821584
)
15831585
elif self.coderunner.running: # TODO does this ever happen?
15841586
cursor_row, cursor_column = divmod(
1585-
(
1586-
len(self.current_cursor_line_without_suggestion)
1587-
+ self.cursor_offset
1588-
),
1587+
len(self.current_cursor_line_without_suggestion)
1588+
+ self.cursor_offset,
15891589
width,
15901590
)
15911591
assert cursor_row >= 0 and cursor_column >= 0, (
@@ -1597,19 +1597,17 @@ def move_screen_up(current_line_start_row):
15971597
)
15981598
else: # Common case for determining cursor position
15991599
cursor_row, cursor_column = divmod(
1600-
(
1601-
wcswidth(self.current_cursor_line_without_suggestion.s)
1602-
- wcswidth(self.current_line)
1603-
+ wcswidth(self.current_line, max(0, self.cursor_offset))
1604-
)
1600+
wcswidth(self.current_cursor_line_without_suggestion.s)
1601+
- wcswidth(self.current_line)
1602+
+ wcswidth(self.current_line, max(0, self.cursor_offset))
16051603
+ self.number_of_padding_chars_on_current_cursor_line(),
16061604
width,
16071605
)
16081606
assert cursor_row >= 0 and cursor_column >= 0, (
16091607
cursor_row,
16101608
cursor_column,
1611-
len(self.current_cursor_line),
1612-
len(self.current_line),
1609+
self.current_cursor_line_without_suggestion.s,
1610+
self.current_line,
16131611
self.cursor_offset,
16141612
)
16151613
cursor_row += current_line_start_row

0 commit comments

Comments
 (0)