chiark / gitweb /
Fix a crash when hitting Return in the editor.
authorSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 21:26:57 +0000 (21:26 +0000)
committerSimon Tatham <anakin@pobox.com>
Thu, 7 Dec 2023 21:26:57 +0000 (21:26 +0000)
cursesclient.py

index 29e11d5baec89987f150869062cdce39bfcc15af..9ad2772e3538c9eabe0746bb27b900339d85b67d 100644 (file)
@@ -712,6 +712,8 @@ class Composer:
                     self.lines.append(text.ColouredString(""))
                     y += 1
                 pos = next_nl + 1
+            if pos == len(self.cs):
+                self.yx[pos] = y, 0
 
     def __init__(self, cc, initial_text="", reply_header=None, reply_id=None):
         self.cc = cc
@@ -900,3 +902,8 @@ class testComposerLayout(unittest.TestCase):
         t.layout(10)
         self.assertEqual(t.lines, [])
         self.assertEqual(t.yx, [(0,0)])
+
+        t = Composer.DisplayText("\n")
+        t.layout(10)
+        self.assertEqual(t.lines, [text.ColouredString("")])
+        self.assertEqual(t.yx, [(0,0),(1,0)])