Skip to content

Commit d4e4ab7

Browse files
authored
Fix overlay selection when tmux fills window-number gaps, close #13 (#14)
- read the current window id from TMUX_PANE instead of assuming the new window is `{end}` - select that window id so the temporary overlay is focused even when tmux reuses skipped numbers - prevent focus jumps and missing highlights when window indexes are non-contiguous
1 parent 6722261 commit d4e4ab7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

easymotion.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ def get_terminal_size():
342342
return width, height - 1 # Subtract 1 from height
343343

344344

345+
def get_current_window_id():
346+
"""Return the window_id for the pane running this script"""
347+
pane_target = os.environ.get("TMUX_PANE")
348+
cmd = ["tmux", "display-message", "-p"]
349+
if pane_target:
350+
cmd.extend(["-t", pane_target])
351+
cmd.append("#{window_id}")
352+
return sh(cmd).strip()
353+
354+
345355
def getch(input_file=None, num_chars=1):
346356
"""Get character(s) from terminal or file
347357
@@ -758,7 +768,8 @@ def main(screen: Screen):
758768
terminal_width, terminal_height = get_terminal_size()
759769
draw_all_panes(panes, max_x, padding_cache, terminal_height, screen)
760770
draw_all_hints(positions, terminal_height, screen)
761-
sh(['tmux', 'select-window', '-t', '{end}'])
771+
overlay_window_id = get_current_window_id()
772+
sh(["tmux", "select-window", "-t", overlay_window_id])
762773

763774
# Handle user input
764775
key_sequence = ""

0 commit comments

Comments
 (0)