]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-119434: Fix culmitive errors in wrapping as lines proceed (GH-119435) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 23 May 2024 03:46:11 +0000 (05:46 +0200)
committerGitHub <noreply@github.com>
Thu, 23 May 2024 03:46:11 +0000 (23:46 -0400)
Fix culmitive errors in wrapping as lines proceed
(cherry picked from commit e3bf5381fd056d0bbdd775463e3724aab2012e45)

Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
Lib/_pyrepl/reader.py

index 9a207a241d5f8d58afa41737f475653363721d71..40cbe422fabdbec0500c50a0d0bef027069f3d31 100644 (file)
@@ -307,7 +307,8 @@ class Reader:
                 screen.append(prompt + l)
                 screeninfo.append((lp, l2))
             else:
-                for i in range(wrapcount + 1):
+                i = 0
+                while l:
                     prelen = lp if i == 0 else 0
                     index_to_wrap_before = 0
                     column = 0
@@ -317,12 +318,17 @@ class Reader:
                         index_to_wrap_before += 1
                         column += character_width
                     pre = prompt if i == 0 else ""
-                    post = "\\" if i != wrapcount else ""
-                    after = [1] if i != wrapcount else []
+                    if len(l) > index_to_wrap_before:
+                        post = "\\"
+                        after = [1]
+                    else:
+                        post = ""
+                        after = []
                     screen.append(pre + l[:index_to_wrap_before] + post)
                     screeninfo.append((prelen, l2[:index_to_wrap_before] + after))
                     l = l[index_to_wrap_before:]
                     l2 = l2[index_to_wrap_before:]
+                    i += 1
         self.screeninfo = screeninfo
         self.cxy = self.pos2xy()
         if self.msg and self.msg_at_bottom: