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)