diff --git a/kitty/boss.py b/kitty/boss.py index 62255700a..335e7f69a 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1443,8 +1443,12 @@ class Boss: matches.append(x) if has_sequence_match: matches = [x for x in matches if x.is_sequence] - q = matches[-1].options.when_focus_on - matches = [x for x in matches if x.options.when_focus_on == q] + terminal_matches = [x for x in matches if not x.rest] + if terminal_matches: + matches = [terminal_matches[-1]] + else: + q = matches[-1].options.when_focus_on + matches = [x for x in matches if x.options.when_focus_on == q] else: matches = [matches[-1]] return matches