@@ -238,7 +238,7 @@ def get_initial_tmux_info():
238238 '#{pane_top},#{pane_height},#{pane_left},#{pane_width},' + \
239239 '#{pane_in_mode},#{scroll_position}'
240240
241- cmd = ['tmux' , 'list-panes' , '-F' , format_str , '-t' , '{last}' ]
241+ cmd = ['tmux' , 'list-panes' , '-F' , format_str ]
242242 output = sh (cmd ).strip ()
243243
244244 panes_info = []
@@ -294,17 +294,7 @@ def __init__(self, pane_id, start_y, height, start_x, width):
294294def tmux_pane_id ():
295295 # Get the ID of the pane that launched this script
296296 source_pane = os .environ .get ('TMUX_PANE' )
297- if not source_pane :
298- return '%0'
299-
300- # We're in a new window, get the pane from the previous window
301- previous_pane = sh (
302- ['tmux' , 'list-panes' , '-F' , '#{pane_id}' , '-t' , '{last}' ]).strip ()
303- if re .match (r'%\d+' , previous_pane ):
304- return previous_pane .split ('\n ' )[0 ]
305-
306- # Fallback to current pane if can't get previous
307- return sh (['tmux' , 'display-message' , '-p' , '#{pane_id}' ]).strip ()
297+ return source_pane or '%0'
308298
309299
310300def get_terminal_size ():
@@ -494,6 +484,7 @@ def main(screen: Screen):
494484
495485 draw_all_panes (panes , max_x , padding_cache , terminal_height , screen )
496486 screen .refresh ()
487+ sh (['tmux' , 'select-window' , '-t' , '{end}' ])
497488
498489 hints = generate_hints (KEYS )
499490 search_ch = getch ()
0 commit comments