summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-23 06:53:09 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-24 02:18:31 +0200
commit31e4ed006d6a56f372681a449dc8a5aefe62f0b7 (patch)
tree619b1bbc2d510f1cea376ee2ee0bcb2bab3a6f83 /src
parent179ed52addea7e6f43110143c55ad4aaaf16b9ba (diff)
listing: fix off by one error in PageDown movement
Diffstat (limited to 'src')
-rw-r--r--src/components/mail/listing/compact.rs2
-rw-r--r--src/components/mail/listing/conversations.rs4
-rw-r--r--src/components/mail/listing/plain.rs8
-rw-r--r--src/components/mail/listing/thread.rs4
4 files changed, 7 insertions, 11 deletions
diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs
index cef0e05a..7882a184 100644
--- a/src/components/mail/listing/compact.rs
+++ b/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(_) => {}
diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs
index edf5645a..966bdac6 100644
--- a/src/components/mail/listing/conversations.rs
+++ b/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);
}
}
}
diff --git a/src/components/mail/listing/plain.rs b/src/components/mail/listing/plain.rs
index 5beda704..e9500131 100644
--- a/src/components/mail/listing/plain.rs
+++ b/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);
}
}
}
diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs
index a0c4e5ea..6c34a5e0 100644
--- a/src/components/mail/listing/thread.rs
+++ b/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);
}
}
}