the args for KeyAction are not just strings

This commit is contained in:
Kovid Goyal 2021-05-28 12:05:24 +05:30
parent f976851442
commit 43ece23b89
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,7 @@ FuncArgsType = Tuple[str, Sequence[Any]]
class KeyAction(NamedTuple): class KeyAction(NamedTuple):
func: str func: str
args: Sequence[str] = () args: Tuple[Union[str, float, bool, int, None], ...] = ()
def __repr__(self) -> str: def __repr__(self) -> str:
if self.args: if self.args:
@ -753,7 +753,7 @@ def parse_key_action(action: str, action_type: str = 'map') -> Optional[KeyActio
except Exception as err: except Exception as err:
log_error(f'Ignoring invalid {action_type} action: {action} with err: {err}') log_error(f'Ignoring invalid {action_type} action: {action} with err: {err}')
else: else:
return KeyAction(func, args) return KeyAction(func, tuple(args))
else: else:
log_error(f'Ignoring unknown {action_type} action: {action}') log_error(f'Ignoring unknown {action_type} action: {action}')
return None return None
@ -766,7 +766,7 @@ class BaseDefinition:
if not self.action.args: if not self.action.args:
return return
kitten = self.action.args[0] kitten = self.action.args[0]
rest = self.action.args[1] if len(self.action.args) > 1 else '' rest = str(self.action.args[1] if len(self.action.args) > 1 else '')
changed = False changed = False
for key, expanded in aliases.items(): for key, expanded in aliases.items():
if key == kitten: if key == kitten:
@ -775,7 +775,7 @@ class BaseDefinition:
if len(expanded) > 1: if len(expanded) > 1:
rest = expanded[1] + ' ' + rest rest = expanded[1] + ' ' + rest
if changed: if changed:
self.action = self.action._replace(args=[kitten, rest.rstrip()]) self.action = self.action._replace(args=(kitten, rest.rstrip()))
class MouseMapping(BaseDefinition): class MouseMapping(BaseDefinition):

View File

@ -1016,7 +1016,7 @@ class Window:
self.current_marker_spec = key self.current_marker_spec = key
def set_marker(self, spec: Union[str, Sequence[str]]) -> None: def set_marker(self, spec: Union[str, Sequence[str]]) -> None:
from .config import parse_marker_spec, toggle_marker from .options.utils import parse_marker_spec, toggle_marker
from .marks import marker_from_spec from .marks import marker_from_spec
if isinstance(spec, str): if isinstance(spec, str):
func, (ftype, spec_, flags) = toggle_marker('toggle_marker', spec) func, (ftype, spec_, flags) = toggle_marker('toggle_marker', spec)