diff --git a/gtm2.py b/gtm2.py index c2d71ce..ad5d7b6 100755 --- a/gtm2.py +++ b/gtm2.py @@ -302,12 +302,18 @@ def draw_selection(stdscr, state): start_x, start_y = state.selection_start_coord end_x, end_y = state.selection_end_coord - # Determine pane from where selection started - pane = 'left' if start_x < state.divider_col else 'right' - if pane == 'left': - pane_x1, pane_x2 = 0, state.divider_col - 1 - else: # right - pane_x1, pane_x2 = state.divider_col + 2, state.width - 1 + # Determine pane boundaries based on sidebar visibility + if state.show_sidebar: + # Determine pane from where selection started + pane = 'left' if start_x < state.divider_col else 'right' + if pane == 'left': + pane_x1, pane_x2 = 0, state.divider_col - 1 + else: # right + pane_x1, pane_x2 = state.divider_col + 2, state.width - 1 + else: + # When sidebar is hidden, there's only the right pane + pane = 'right' + pane_x1, pane_x2 = 0, state.width - 1 # Determine drag direction to handle multi-line selection correctly if start_y < end_y or (start_y == end_y and start_x <= end_x): @@ -466,12 +472,18 @@ def copy_selection_to_clipboard(stdscr, state): start_x, start_y = state.selection_start_coord end_x, end_y = state.selection_end_coord - # Determine pane from where selection started - pane = 'left' if start_x < state.divider_col else 'right' - if pane == 'left': - pane_x1, pane_x2 = 0, state.divider_col - 1 - else: # right - pane_x1, pane_x2 = state.divider_col + 2, state.width - 1 + # Determine pane boundaries based on sidebar visibility + if state.show_sidebar: + # Determine pane from where selection started + pane = 'left' if start_x < state.divider_col else 'right' + if pane == 'left': + pane_x1, pane_x2 = 0, state.divider_col - 1 + else: # right + pane_x1, pane_x2 = state.divider_col + 2, state.width - 1 + else: + # When sidebar is hidden, there's only the right pane + pane = 'right' + pane_x1, pane_x2 = 0, state.width - 1 # Determine drag direction to handle multi-line selection correctly if start_y < end_y or (start_y == end_y and start_x <= end_x):