diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 13 |
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; |