diff --git a/kitty/open_actions.py b/kitty/open_actions.py index 5044c9b19..3ad087c93 100644 --- a/kitty/open_actions.py +++ b/kitty/open_actions.py @@ -61,8 +61,7 @@ def parse(lines: Iterable[str]) -> Iterator[OpenAction]: alias_name, alias_val = rest.split(maxsplit=1) except Exception: continue - is_recursive = alias_name == alias_val.split(maxsplit=1)[0] - alias_map[alias_name] = [ActionAlias(alias_name, alias_val, is_recursive)] + alias_map[alias_name] = [ActionAlias(alias_name, alias_val)] else: log_error(f'Ignoring malformed open actions line: {line}') diff --git a/kitty/options/utils.py b/kitty/options/utils.py index 00eb5e84f..0fb91a527 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -819,7 +819,6 @@ def parse_key_action(action: str, action_type: str = 'map') -> KeyAction: class ActionAlias(NamedTuple): name: str value: str - is_recursive: bool replace_second_arg: bool = False @@ -827,12 +826,10 @@ def build_action_aliases(raw: Dict[str, str], first_arg_replacement: str = '') - ans: Dict[str, List[ActionAlias]] = {} if first_arg_replacement: for alias_name, rest in raw.items(): - is_recursive = alias_name == rest.split(maxsplit=1)[0] - ans.setdefault(first_arg_replacement, []).append(ActionAlias(alias_name, rest, is_recursive, True)) + ans.setdefault(first_arg_replacement, []).append(ActionAlias(alias_name, rest, True)) else: for alias_name, rest in raw.items(): - is_recursive = alias_name == rest.split(maxsplit=1)[0] - ans[alias_name] = [ActionAlias(alias_name, rest, is_recursive)] + ans[alias_name] = [ActionAlias(alias_name, rest)] return ans @@ -854,18 +851,14 @@ def resolve_aliases_and_parse_actions( if parts[0] != alias.name: continue new_defn = possible_alias + ' ' + alias.value + ((' ' + parts[1]) if len(parts) > 1 else '') - new_aliases = aliases - if alias.is_recursive: - new_aliases = aliases.copy() - new_aliases[possible_alias] = [a for a in aliases[possible_alias] if a is not alias] + new_aliases = aliases.copy() + new_aliases[possible_alias] = [a for a in aliases[possible_alias] if a is not alias] yield from resolve_aliases_and_parse_actions(new_defn, new_aliases, map_type) return else: # action_alias new_defn = alias.value + ((' ' + rest) if rest else '') - new_aliases = aliases - if alias.is_recursive: - new_aliases = aliases.copy() - new_aliases.pop(possible_alias) + new_aliases = aliases.copy() + new_aliases.pop(possible_alias) yield from resolve_aliases_and_parse_actions(new_defn, new_aliases, map_type) return diff --git a/kitty_tests/options.py b/kitty_tests/options.py index d0f4a2572..0e10a8260 100644 --- a/kitty_tests/options.py +++ b/kitty_tests/options.py @@ -76,6 +76,11 @@ class TestConfParsing(BaseTest): self.ae(ka.func, 'launch') self.ae(ka.args, ('--moo', 'recursive', 'XXX')) + opts = p('clear_all_shortcuts y', 'action_alias launch two 1', 'action_alias two launch 2', 'map f1 launch 3') + ka = tuple(opts.keymap.values())[0][0] + self.ae(ka.func, 'launch') + self.ae(ka.args, ('2', '1', '3')) + opts = p('clear_all_shortcuts y', 'action_alias launch launch --moo', 'map f1 launch XXX') ka = tuple(opts.keymap.values())[0][0] self.ae(ka.func, 'launch')