Skip to content

Commit e3bf538

Browse files
authored
gh-119434: Fix culmitive errors in wrapping as lines proceed (#119435)
Fix culmitive errors in wrapping as lines proceed
1 parent 9b422fc commit e3bf538

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Lib/_pyrepl/reader.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def calc_complete_screen(self) -> list[str]:
307307
screen.append(prompt + l)
308308
screeninfo.append((lp, l2))
309309
else:
310-
for i in range(wrapcount + 1):
310+
i = 0
311+
while l:
311312
prelen = lp if i == 0 else 0
312313
index_to_wrap_before = 0
313314
column = 0
@@ -317,12 +318,17 @@ def calc_complete_screen(self) -> list[str]:
317318
index_to_wrap_before += 1
318319
column += character_width
319320
pre = prompt if i == 0 else ""
320-
post = "\\" if i != wrapcount else ""
321-
after = [1] if i != wrapcount else []
321+
if len(l) > index_to_wrap_before:
322+
post = "\\"
323+
after = [1]
324+
else:
325+
post = ""
326+
after = []
322327
screen.append(pre + l[:index_to_wrap_before] + post)
323328
screeninfo.append((prelen, l2[:index_to_wrap_before] + after))
324329
l = l[index_to_wrap_before:]
325330
l2 = l2[index_to_wrap_before:]
331+
i += 1
326332
self.screeninfo = screeninfo
327333
self.cxy = self.pos2xy()
328334
if self.msg and self.msg_at_bottom:

0 commit comments

Comments
 (0)