From: Simon Tatham Date: Sat, 9 Dec 2023 18:44:21 +0000 (+0000) Subject: Fix file-position stability over backward extend. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=2dd4620aac3d21b3ffa9c1cee01ab72c37f24f63;p=mastodonochrome.git Fix file-position stability over backward extend. That last-minute idea to bound pos_within_item within the actual size of the item ... forgot that each logical item (e.g. a status) is made up of multiple physical items (paragraphs, separator line, etc), so I bounded it within _those_ and made a mess. Should be back to normal now. --- diff --git a/cursesclient.py b/cursesclient.py index c5a9ed5..3e8c0c0 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -622,18 +622,22 @@ class ObjectFile(File): self.lines = [] self.index_by_line = [] pos = 0 + last_itemindex = None + curr_itemtop = 0 for thing, itemindex in self.iter_text_indexed(): params = {} if (self.mode == 'select' and itemindex == self.select_target and hasattr(thing, 'can_highlight_as_target')): params['target'] = True - oldlen = len(self.lines) + if itemindex != last_itemindex: + curr_itemtop = len(self.lines) + last_itemindex = itemindex for line in thing.render(width, **params): for s in line.split(width): self.lines.append(s) self.index_by_line.append(itemindex) if itemindex == self.itempos: - itemheight = len(self.lines) - oldlen + itemheight = len(self.lines) - curr_itemtop pos = len(self.lines) - min(pos_within_item, itemheight) self.width = width