fix: Correct scroll percentages and commit message display

This commit is contained in:
n loewen (aider) 2025-06-08 08:55:20 +01:00
parent dba40cbe85
commit a804ebe85a
1 changed files with 10 additions and 8 deletions

18
gtm
View File

@ -867,7 +867,7 @@ def draw_status_bars(stdscr, state):
if len(state.file_lines) > 0:
last_visible_line = state.right_scroll_offset + visible_height
right_percent = int((last_visible_line / len(state.file_lines)) * 100)
right_percent = 100 if last_visible_line >= len(state.file_lines) else right_percent
right_percent = min(100, right_percent)
else:
right_percent = 0
right_status = f"{right_percent}%"
@ -875,7 +875,7 @@ def draw_status_bars(stdscr, state):
if len(state.commits) > 0 and state.show_sidebar:
last_visible_commit = state.left_scroll_offset + visible_height
left_percent = int((last_visible_commit / len(state.commits)) * 100)
left_percent = 100 if last_visible_commit >= len(state.commits) else left_percent
left_percent = min(100, left_percent)
else:
left_percent = 0
left_status = f"{left_percent}%"
@ -960,19 +960,20 @@ def draw_status_bars(stdscr, state):
available_message_lines = state.status_bar_height - 1
try:
# Draw the commit hash with bold on the first line of the status bar
stdscr.addstr(state.height - state.status_bar_height + 1, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
# Draw the commit hash with bold on the bottom line of the status bar
bottom_line = state.height - 1
stdscr.addstr(bottom_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
# Draw the author and branch on the right of the first line
# Draw the author and branch on the right of the bottom line
right_x = state.width - len(author_branch_info)
if right_x >= 0:
stdscr.addstr(state.height - state.status_bar_height + 1, right_x, author_branch_info, curses.A_REVERSE)
stdscr.addstr(bottom_line, right_x, author_branch_info, curses.A_REVERSE)
# Draw the first line of the commit message on the same line as the hash
first_line = message_lines[0]
if len(first_line) > available_width:
first_line = first_line[:available_width-3] + "..."
stdscr.addstr(state.height - state.status_bar_height + 1, len(commit_info), first_line, curses.A_REVERSE)
stdscr.addstr(bottom_line, len(commit_info), first_line, curses.A_REVERSE)
# Draw additional lines of the commit message if we have space
for i in range(1, min(available_message_lines, len(message_lines))):
@ -982,7 +983,8 @@ def draw_status_bars(stdscr, state):
if len(line) > line_available_width:
line = line[:line_available_width-3] + "..."
# Draw the line with some indentation
stdscr.addstr(state.height - state.status_bar_height + 1 + i, 4, line, curses.A_REVERSE)
line_y = bottom_line - i
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
except curses.error:
pass