chiark / gitweb /
Fix extending a totally empty home timeline.
authorSimon Tatham <anakin@pobox.com>
Sun, 31 Dec 2023 13:46:49 +0000 (13:46 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 31 Dec 2023 14:06:32 +0000 (14:06 +0000)
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

index ae2427d9507e5073e6f7569883b76205cf8f894f..da42aaf6e20499ee9f40c4fec4d188128ebc39d5 100644 (file)
@@ -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<Type: FeedType> ActivityState for FeedFile<Type> {
                                 // 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<Type: FeedType> ActivityState for FeedFile<Type> {
                         },
                         Err(e) => LogicalAction::Error(e),
                     };
+                    self.ensure_enough_rendered();
                     action
                 } else {
                     self.goto_top();