From: Simon Tatham Date: Thu, 7 Dec 2023 21:26:57 +0000 (+0000) Subject: Fix a crash when hitting Return in the editor. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=b1d0d1f98c90a6563507c91338e8a04ffd618fea;p=mastodonochrome.git Fix a crash when hitting Return in the editor. --- diff --git a/cursesclient.py b/cursesclient.py index 29e11d5..9ad2772 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -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)])