From 29f0e7a28be385308bfe4ad3bdd9d67cbd75de7a Mon Sep 17 00:00:00 2001 From: n loewen Date: Wed, 23 Apr 2025 22:04:40 +0100 Subject: [PATCH] Clamp scrolling to file contents --- git_time_machine.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git_time_machine.py b/git_time_machine.py index 2f32e1c..2ae8d61 100644 --- a/git_time_machine.py +++ b/git_time_machine.py @@ -76,12 +76,13 @@ def main(stdscr, filename): elif focus == "right": if key == curses.KEY_DOWN or key == ord('j'): - scroll_offset += 1 + if scroll_offset < max(0, len(file_lines) - height): + scroll_offset += 1 elif key == curses.KEY_UP or key == ord('k'): if scroll_offset > 0: scroll_offset -= 1 elif key == curses.KEY_NPAGE: # Page Down - scroll_offset += height + scroll_offset = min(scroll_offset + height, max(0, len(file_lines) - height)) elif key == curses.KEY_PPAGE: # Page Up scroll_offset = max(0, scroll_offset - height)