aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-04-21 01:34:24 -0700
committerJames Campos <james.r.campos@gmail.com>2020-04-21 01:34:24 -0700
commit3f2faf4167a7783b30564c09d3b782938e35e3e0 (patch)
tree52497b60e5e1755efb4f1cd5a9577af70f1ff2f2 /src/main.rs
parentdd520811d2a05492f7ab7b2211ca7945e1f8e10a (diff)
downloadbk-3f2faf4167a7783b30564c09d3b782938e35e3e0.tar.gz
saturating
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index e232c40..280aa2a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -202,11 +202,7 @@ impl Bk {
| KeyCode::PageUp
| KeyCode::Char('h') => {
if self.pos > 0 {
- if self.pos < self.rows {
- self.pos = 0;
- } else {
- self.pos -= self.rows;
- }
+ self.pos = self.pos.saturating_sub(self.rows);
} else if self.chapter_idx > 0 {
self.get_chapter(self.chapter_idx - 1);
self.pos = (self.chapter.len() / self.rows) * self.rows;