diff options
author | James Campos <james.r.campos@gmail.com> | 2020-04-21 01:34:24 -0700 |
---|---|---|
committer | James Campos <james.r.campos@gmail.com> | 2020-04-21 01:34:24 -0700 |
commit | 3f2faf4167a7783b30564c09d3b782938e35e3e0 (patch) | |
tree | 52497b60e5e1755efb4f1cd5a9577af70f1ff2f2 | |
parent | dd520811d2a05492f7ab7b2211ca7945e1f8e10a (diff) | |
download | bk-3f2faf4167a7783b30564c09d3b782938e35e3e0.tar.gz |
saturating
-rw-r--r-- | src/main.rs | 6 |
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; |