diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index 68cb0bef..fa8efe20 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -220,6 +220,8 @@ impl ListingTrait for CompactListing { PageMovement::PageDown => { if self.new_cursor_pos.2 + rows + 1 < self.length { self.new_cursor_pos.2 += rows; + } else if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; } else { self.new_cursor_pos.2 = (self.length / rows) * rows; } @@ -228,7 +230,11 @@ impl ListingTrait for CompactListing { self.new_cursor_pos.2 = 0; } PageMovement::End => { - self.new_cursor_pos.2 = (self.length / rows) * rows; + if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; + } else { + self.new_cursor_pos.2 = (self.length / rows) * rows; + } } } } diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index df28ac71..5078d5d7 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -137,6 +137,8 @@ impl ListingTrait for PlainListing { PageMovement::PageDown => { if self.new_cursor_pos.2 + rows + 1 < self.length { self.new_cursor_pos.2 += rows; + } else if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; } else { self.new_cursor_pos.2 = (self.length / rows) * rows; } @@ -145,7 +147,11 @@ impl ListingTrait for PlainListing { self.new_cursor_pos.2 = 0; } PageMovement::End => { - self.new_cursor_pos.2 = (self.length / rows) * rows; + if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; + } else { + self.new_cursor_pos.2 = (self.length / rows) * rows; + } } } } diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index de9537dd..6dad325f 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -73,6 +73,33 @@ impl ListingTrait for ThreadListing { return; } let rows = get_y(bottom_right) - get_y(upper_left) + 1; + if let Some(mvm) = self.movement.take() { + match mvm { + PageMovement::PageUp => { + self.new_cursor_pos.2 = self.new_cursor_pos.2.saturating_sub(rows); + } + PageMovement::PageDown => { + if self.new_cursor_pos.2 + rows + 1 < self.length { + self.new_cursor_pos.2 += rows; + } else if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; + } else { + self.new_cursor_pos.2 = (self.length / rows) * rows; + } + } + PageMovement::Home => { + self.new_cursor_pos.2 = 0; + } + PageMovement::End => { + if self.new_cursor_pos.2 + rows > self.length { + self.new_cursor_pos.2 = self.length - 1; + } else { + self.new_cursor_pos.2 = (self.length / rows) * rows; + } + } + } + } + let prev_page_no = (self.cursor_pos.2).wrapping_div(rows); let page_no = (self.new_cursor_pos.2).wrapping_div(rows);