Browse Source

listing: fix off by one error in PageDown movement

jmap-eventsource
Manos Pitsidianakis 1 year ago
parent
commit
31e4ed006d
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 2
      src/components/mail/listing/compact.rs
  2. 4
      src/components/mail/listing/conversations.rs
  3. 8
      src/components/mail/listing/plain.rs
  4. 4
      src/components/mail/listing/thread.rs

2
src/components/mail/listing/compact.rs

@ -555,7 +555,7 @@ impl ListingTrait for CompactListing {
} else if self.new_cursor_pos.2 + rows * multiplier > self.length {
self.new_cursor_pos.2 = self.length - 1;
} else {
self.new_cursor_pos.2 = (self.length / rows) * rows;
self.new_cursor_pos.2 = (self.length.saturating_sub(1) / rows) * rows;
}
}
PageMovement::Right(_) | PageMovement::Left(_) => {}

4
src/components/mail/listing/conversations.rs

@ -638,7 +638,7 @@ impl ListingTrait for ConversationsListing {
} else if self.new_cursor_pos.2 + rows * multiplier > self.length {
self.new_cursor_pos.2 = self.length - 1;
} else {
self.new_cursor_pos.2 = (self.length / rows) * rows;
self.new_cursor_pos.2 = (self.length.saturating_sub(1) / rows) * rows;
}
}
PageMovement::Right(_) | PageMovement::Left(_) => {}
@ -646,7 +646,7 @@ impl ListingTrait for ConversationsListing {
self.new_cursor_pos.2 = 0;
}
PageMovement::End => {
self.new_cursor_pos.2 = self.length - 1;
self.new_cursor_pos.2 = self.length.saturating_sub(1);
}
}
}

8
src/components/mail/listing/plain.rs

@ -440,7 +440,7 @@ impl ListingTrait for PlainListing {
} else if self.new_cursor_pos.2 + rows * multiplier > self.length {
self.new_cursor_pos.2 = self.length - 1;
} else {
self.new_cursor_pos.2 = (self.length / rows) * rows;
self.new_cursor_pos.2 = (self.length.saturating_sub(1) / rows) * rows;
}
}
PageMovement::Right(_) | PageMovement::Left(_) => {}
@ -448,11 +448,7 @@ impl ListingTrait for PlainListing {
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;
}
self.new_cursor_pos.2 = self.length.saturating_sub(1);
}
}
}

4
src/components/mail/listing/thread.rs

@ -463,7 +463,7 @@ impl ListingTrait for ThreadListing {
} else if self.new_cursor_pos.2 + rows * multiplier > self.length {
self.new_cursor_pos.2 = self.length - 1;
} else {
self.new_cursor_pos.2 = (self.length / rows) * rows;
self.new_cursor_pos.2 = (self.length.saturating_sub(1) / rows) * rows;
}
}
PageMovement::Right(_) | PageMovement::Left(_) => {}
@ -471,7 +471,7 @@ impl ListingTrait for ThreadListing {
self.new_cursor_pos.2 = 0;
}
PageMovement::End => {
self.new_cursor_pos.2 = self.length - 1;
self.new_cursor_pos.2 = self.length.saturating_sub(1);
}
}
}

Loading…
Cancel
Save