refactor: Simplify commit details drawing by removing unnecessary try-except block
This commit is contained in:
parent
ecb59fa6c4
commit
328f0de01d
57
gtm
57
gtm
|
|
@ -931,41 +931,38 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
|
|||
if not message_lines:
|
||||
message_lines = [""]
|
||||
|
||||
try:
|
||||
# Draw on the second line of the status bar (layout.commit_detail_start_y)
|
||||
second_line = layout.commit_detail_start_y
|
||||
# Draw on the second line of the status bar (layout.commit_detail_start_y)
|
||||
second_line = layout.commit_detail_start_y
|
||||
|
||||
# Draw the commit hash with bold at the start
|
||||
commit_info = f" {state.commit_hash} "
|
||||
stdscr.addstr(second_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
||||
# Draw the commit hash with bold at the start
|
||||
commit_info = f" {state.commit_hash} "
|
||||
stdscr.addstr(second_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
||||
|
||||
# Draw the author and branch on the right
|
||||
author_branch_info = f" {state.commit_author} [{state.commit_branch}] "
|
||||
right_x = layout.screen_width - len(author_branch_info)
|
||||
if right_x >= 0:
|
||||
stdscr.addstr(second_line, right_x, author_branch_info, curses.A_REVERSE)
|
||||
# Draw the author and branch on the right
|
||||
author_branch_info = f" {state.commit_author} [{state.commit_branch}] "
|
||||
right_x = layout.screen_width - len(author_branch_info)
|
||||
if right_x >= 0:
|
||||
stdscr.addstr(second_line, right_x, author_branch_info, curses.A_REVERSE)
|
||||
|
||||
# Draw the first line of the commit message in between
|
||||
available_width = layout.screen_width - len(commit_info) - len(author_branch_info) - 1
|
||||
first_line = message_lines[0] if message_lines else ""
|
||||
if len(first_line) > available_width:
|
||||
first_line = first_line[:available_width-3] + "..."
|
||||
stdscr.addstr(second_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||
# Draw the first line of the commit message in between
|
||||
available_width = layout.screen_width - len(commit_info) - len(author_branch_info) - 1
|
||||
first_line = message_lines[0] if message_lines else ""
|
||||
if len(first_line) > available_width:
|
||||
first_line = first_line[:available_width-3] + "..."
|
||||
stdscr.addstr(second_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||
|
||||
# Draw additional lines of the commit message if we have more space
|
||||
for i, line in enumerate(message_lines[1:], 1):
|
||||
line_y = layout.commit_detail_start_y + i
|
||||
if line_y >= layout.start_y + layout.total_height:
|
||||
break # No more space
|
||||
# Draw additional lines of the commit message if we have more space
|
||||
for i, line in enumerate(message_lines[1:], 1):
|
||||
line_y = layout.commit_detail_start_y + i
|
||||
if line_y >= layout.start_y + layout.total_height:
|
||||
break # No more space
|
||||
|
||||
# For continuation lines, indent them
|
||||
line_available_width = layout.screen_width - 4 # Leave some margin
|
||||
if len(line) > line_available_width:
|
||||
line = line[:line_available_width-3] + "..."
|
||||
# For continuation lines, indent them
|
||||
line_available_width = layout.screen_width - 4 # Leave some margin
|
||||
if len(line) > line_available_width:
|
||||
line = line[:line_available_width-3] + "..."
|
||||
|
||||
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
|
||||
except curses.error:
|
||||
pass
|
||||
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
|
||||
|
||||
def draw_search_mode(stdscr, state: AppState, layout: StatusBarLayout):
|
||||
"""Draw search input interface"""
|
||||
|
|
@ -1206,7 +1203,7 @@ def handle_mouse_input(stdscr, state: AppState) -> AppState:
|
|||
# or very close to the same position (within 1-2 pixels)
|
||||
if (state.click_position and
|
||||
abs(state.click_position[0] - mx) <= 2 and
|
||||
abs(state.click_position[1] - my) <= 2):
|
||||
abs(state.click_position[1] - my) <= 2): # TODO don't do this <= 2 thing
|
||||
# This was a click, so switch panes (only if sidebar is visible)
|
||||
focus = "right"
|
||||
if state.show_sidebar:
|
||||
|
|
|
|||
Loading…
Reference in New Issue