aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-04-19 07:42:58 -0700
committerJames Campos <james.r.campos@gmail.com>2020-04-19 07:42:58 -0700
commit73b16d35bb72b326e512eb85e6eea0830c8ec124 (patch)
tree5fb2693568b8b9baa3cf367c82727dc8883b1857 /src
parentd2991ae015555d4982bc27e1e492c8483e5313c8 (diff)
downloadbk-73b16d35bb72b326e512eb85e6eea0830c8ec124.tar.gz
bounds
Diffstat (limited to 'src')
-rw-r--r--src/main.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 877f9e3..c21f7c2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -160,9 +160,11 @@ impl Bk {
}
}
KeyCode::Char('n') => {
- self.pos = 0;
- self.chapter_idx += 1;
- self.load_chapter();
+ if self.chapter_idx < self.toc.len() - 1 {
+ self.pos = 0;
+ self.chapter_idx += 1;
+ self.load_chapter();
+ }
}
KeyCode::Char('h')
| KeyCode::Char('k')
@@ -182,8 +184,9 @@ impl Bk {
| KeyCode::Char('j')
| KeyCode::Char('l')
| KeyCode::Char(' ') => {
- self.pos += self.rows;
- if self.pos >= self.chapter.len() {
+ if self.pos + self.rows < self.chapter.len() {
+ self.pos += self.rows;
+ } else if self.chapter_idx < self.toc.len() - 1 {
self.chapter_idx += 1;
self.load_chapter();
self.pos = 0;