Skip to content

Commit 3390cd7

Browse files
Fix #909
Static types would have helped! I'll add some.
1 parent 78ead4c commit 3390cd7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def __init__(
367367
self._current_line = ""
368368

369369
# current line of output - stdout and stdin go here
370-
self.current_stdouterr_line = ""
370+
self.current_stdouterr_line = "" # Union[str, FmtStr]
371371

372372
# this is every line that's been displayed (input and output)
373373
# as with formatting applied. Logical lines that exceeded the terminal width
@@ -1582,8 +1582,18 @@ def move_screen_up(current_line_start_row):
15821582
current_line_height = current_line_end_row - current_line_start_row
15831583

15841584
if self.stdin.has_focus:
1585+
logger.debug(
1586+
"stdouterr when self.stdin has focus: %r %r",
1587+
type(self.current_stdouterr_line),
1588+
self.current_stdouterr_line,
1589+
)
1590+
stdouterr_width = (
1591+
self.current_stdouterr_line.width
1592+
if isinstance(self.current_stdouterr_line, FmtStr)
1593+
else wcswidth(self.current_stdouterr_line)
1594+
)
15851595
cursor_row, cursor_column = divmod(
1586-
wcswidth(self.current_stdouterr_line)
1596+
stdouterr_width
15871597
+ wcswidth(
15881598
self.stdin.current_line, max(0, self.stdin.cursor_offset)
15891599
),

0 commit comments

Comments
 (0)