From ab3af5ea60167d0d9e419bcd67020cb897f9156c Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sun, 8 Jun 2025 10:25:07 +0100 Subject: [PATCH] fix: Prevent last file lines from being hidden by status bar --- gtm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/gtm b/gtm index 6aa7bd3..b01137d 100755 --- a/gtm +++ b/gtm @@ -361,13 +361,21 @@ def page_commit_selection(state: AppState, direction: int) -> AppState: return move_commit_selection(state, delta) def scroll_right_pane(state: AppState, delta: int) -> AppState: - max_scroll = max(0, len(state.file_lines) - (state.height - 1)) + # Calculate visible height accounting for status bar + visible_height = state.height - state.status_bar_height + + # Calculate maximum scroll position + max_scroll = max(0, len(state.file_lines) - visible_height) + + # Apply scroll delta and clamp to valid range new_offset = state.right_scroll_offset + delta new_offset = max(0, min(new_offset, max_scroll)) + return replace(state, right_scroll_offset=new_offset) def page_right_pane(state: AppState, direction: int) -> AppState: - page_size = state.height - 1 + # Calculate page size accounting for status bar + page_size = state.height - state.status_bar_height delta = page_size * direction return scroll_right_pane(state, delta) @@ -538,10 +546,15 @@ def draw_right_pane(stdscr, state): right_width = state.width - right_start - 1 - max_scroll = max(0, len(state.file_lines) - (state.height - state.status_bar_height)) + # Calculate the visible height (accounting for status bar) + visible_height = state.height - state.status_bar_height + + # Calculate maximum scroll position + max_scroll = max(0, len(state.file_lines) - visible_height) state.right_scroll_offset = min(state.right_scroll_offset, max_scroll) - visible_lines = state.file_lines[state.right_scroll_offset:state.right_scroll_offset + state.height - state.status_bar_height] + # Get visible lines based on the calculated visible height + visible_lines = state.file_lines[state.right_scroll_offset:state.right_scroll_offset + visible_height] display_lines = [] deleted_line_map = {} @@ -1213,6 +1226,10 @@ def update_status_bar_height(state: AppState, my: int) -> AppState: # Clamp to allowed range new_height = max(min_height, min(new_height, max_height)) + # Ensure we're not hiding too much content + content_height = max(state.height - new_height, 5) # At least 5 lines for content + new_height = min(new_height, state.height - content_height) + return replace(state, status_bar_height=new_height) def handle_mouse_input(stdscr, state: AppState) -> AppState: