Skip to content

Commit fb8a444

Browse files
committed
fix: handle no match case
1 parent 2351281 commit fb8a444

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

easymotion.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,18 +619,16 @@ def draw_all_hints(positions, terminal_height, screen):
619619
@perf_timer("Total execution")
620620
def main(screen: Screen):
621621
setup_logging()
622-
terminal_width, terminal_height = get_terminal_size()
623622
panes, max_x, padding_cache = init_panes()
624-
current_pane = next(p for p in panes if p.active)
625-
draw_all_panes(panes, max_x, padding_cache, terminal_height, screen)
626623

627624
# Read character from temporary file
628625
search_ch = getch(sys.argv[1])
629626
if search_ch == '\x03':
630627
return
631-
sh(['tmux', 'select-window', '-t', '{end}'])
632628
matches = find_matches(panes, search_ch)
633-
629+
if len(matches) == 0:
630+
sh(['tmux', 'display-message', 'no match'])
631+
return
634632
# If only one match, jump directly
635633
if len(matches) == 1:
636634
pane, line_num, col = matches[0]
@@ -639,6 +637,7 @@ def main(screen: Screen):
639637
return
640638

641639
# Get cursor position from current pane
640+
current_pane = next(p for p in panes if p.active)
642641
cursor_y = current_pane.start_y + current_pane.cursor_y
643642
cursor_x = current_pane.start_x + current_pane.cursor_x
644643
logging.debug(f"Cursor position: {current_pane.pane_id}, {
@@ -664,7 +663,10 @@ def main(screen: Screen):
664663
)]
665664
]
666665

666+
terminal_width, terminal_height = get_terminal_size()
667+
draw_all_panes(panes, max_x, padding_cache, terminal_height, screen)
667668
draw_all_hints(positions, terminal_height, screen)
669+
sh(['tmux', 'select-window', '-t', '{end}'])
668670

669671
# Handle user input
670672
key_sequence = ""

0 commit comments

Comments
 (0)