master-key.replayFromHistory
Replay previously typed master keybindings.
Master key has no knowledge of commands or keybindings that were not run from a
keybinding defined in a master keybinding file. This is because the command history is implemented by pushing each command called with master-key.do
to an array. Commands that only call master-key.prefix
are not recorded, since they do not need to be replayed to reproduce the ultimate effect of a keybinding.
All commands are recorded, up until the the history limit (defined by the Command History Maximum
). When selecting command history to replay, you use one or more expressions
An expression is evaluated at each valid index
of commandHistory
. Evaluation occurs from most recent command (largest index) to least recent command (smallest indx), selecting the first index where the expression evaluates to a truthy value. The structure of each command in commandHistory
is exactly the format used to represent the commands in a master keybinding file.
Arguments
There are two ways the history can be selected:
whereComputedRangeIs.from
: an expression specifying the first command to push to the stackwhereComputedRangeIs.to
: an expression specifying the last command to push to the stack
OR
whereComputedIndexIs
: an expression specifying the single command to push to the stack
Example
As an example, here's how Larkin runs the most recently run action.
[[bind]]
defaults = "edit.action.history"
name = "repeat action"
key = "."
command = "runCommands"
computedRepeat = "count"
[[bind.args.commands]]
command = "master-key.replayFromHistory"
args.whereComputedIndexIs = """
commandHistory[index].defaults.startsWith('edit.action') &&
(!commandHistory[index].defaults.startsWith('edit.action.history') ||
commandHistory[index].name == 'replay')
"""
[[bind.args.commands]]
command = "master-key.enterNormal"
The key argument of relevance here is the expression defined in args.whereComputedIndexIs
where we select the most recent command that is an edit.action
, excluding those actions that are used to replay actions themselves.