fix: Prevent last file lines from being hidden by status bar

This commit is contained in:
n loewen (aider) 2025-06-08 10:25:07 +01:00
parent 9bf0c08fe7
commit ab3af5ea60
1 changed files with 21 additions and 4 deletions

25
gtm
View File

@ -361,13 +361,21 @@ def page_commit_selection(state: AppState, direction: int) -> AppState:
return move_commit_selection(state, delta) return move_commit_selection(state, delta)
def scroll_right_pane(state: AppState, delta: int) -> AppState: 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 = state.right_scroll_offset + delta
new_offset = max(0, min(new_offset, max_scroll)) new_offset = max(0, min(new_offset, max_scroll))
return replace(state, right_scroll_offset=new_offset) return replace(state, right_scroll_offset=new_offset)
def page_right_pane(state: AppState, direction: int) -> AppState: 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 delta = page_size * direction
return scroll_right_pane(state, delta) return scroll_right_pane(state, delta)
@ -538,10 +546,15 @@ def draw_right_pane(stdscr, state):
right_width = state.width - right_start - 1 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) 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 = [] display_lines = []
deleted_line_map = {} deleted_line_map = {}
@ -1213,6 +1226,10 @@ def update_status_bar_height(state: AppState, my: int) -> AppState:
# Clamp to allowed range # Clamp to allowed range
new_height = max(min_height, min(new_height, max_height)) 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) return replace(state, status_bar_height=new_height)
def handle_mouse_input(stdscr, state: AppState) -> AppState: def handle_mouse_input(stdscr, state: AppState) -> AppState: