From bfe885071173fdbc5f2a46ba5e6fa9cc8e9876c2 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 31 Dec 2023 13:46:49 +0000 Subject: [PATCH] Fix extending a totally empty home timeline. Again, probably only likely to come up in a new dev instance - but in that situation, you do need it to work! --- src/file.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/file.rs b/src/file.rs index ae2427d..da42aaf 100644 --- a/src/file.rs +++ b/src/file.rs @@ -15,6 +15,15 @@ enum FilePosition { Fine(isize, usize), // line #n of this item is just off bottom of screen } +impl FilePosition { + fn item(&self) -> isize { + match self { + FilePosition::Coarse(item) => *item, + FilePosition::Fine(item, _) => *item, + } + } +} + trait FeedType { type Item: TextFragment + Sized; @@ -446,6 +455,15 @@ impl ActivityState for FeedFile { // Can't extend this any further into the past // FIXME: this is not tested yet self.contents.extender = None; + if self.pos.item() <= self.contents.origin { + self.coarsen_pos(); + if self.pos.item() < + self.contents.first_index() + { + self.pos = FilePosition::Coarse( + self.contents.first_index()); + } + } } self.contents.update_items(client); @@ -453,6 +471,7 @@ impl ActivityState for FeedFile { }, Err(e) => LogicalAction::Error(e), }; + self.ensure_enough_rendered(); action } else { self.goto_top(); -- 2.30.2