Support array-based key bindings (execute multiple commands) - #235
Support array-based key bindings (execute multiple commands)#235Yaruani wants to merge 2 commits into
Conversation
Changed the "Keys" type definition from "string" to "any" to support array-based command sequences and prevent validation errors.
Modified buildKeyCommand to handle both string and array inputs. If an array is provided, it iterates through and executes each command in sequence.
wshanks
left a comment
There was a problem hiding this comment.
This looks nice. Can you also add something to the "Command syntax" section of the readme about using arrays of strings instead of single strings?
| // This function is based on the default callback in Mousetrap but is extended | ||
| // to include more text input fields that are specific to Thunderbird. | ||
| // Additionally, it does not ignore text fields if the first key includes | ||
| // modifiers other than shift. |
There was a problem hiding this comment.
I don't think this comment needed to be removed?
| // command should be a string formatted as type:body OR an array of strings. | ||
| // Modified to support multiple commands in an array. |
There was a problem hiding this comment.
I'd like to keep the description of the string formatting (line wrapping might not be right for this suggestion):
| // command should be a string formatted as type:body OR an array of strings. | |
| // Modified to support multiple commands in an array. | |
| // command should be a string or arrays of strings with | |
| // each string formatted as type:body where type is cmd, func, | |
| // tbkeys, unset, or eval and body is the type-specific content of the command |
| eval(command); | ||
| break; | ||
| // Internal helper to execute a single command string | ||
| const runSingleCommand = (cmdStr) => { |
There was a problem hiding this comment.
Can we pull this definition outside of buildKeyCommand?
| // | ||
| // keyBindings has the structure: | ||
| // {windowType: {keySequence: keyCommand}} | ||
| // {windowType: {keySequence: keyCommand}} |
There was a problem hiding this comment.
Maybe undo this change unless there was a reason for it?
| "type": "object", | ||
| "description": "Mapping of key sequences to commands", | ||
| "additionalProperties": { "type": "string" } | ||
| "additionalProperties": { "type": "any" } |
There was a problem hiding this comment.
We are going from allowing strings to allow arrays of strings. Can we keep the schema more restricted to those cases instead of using any?
| "additionalProperties": { "type": "any" } | |
| "additionalProperties": { "type": ["array", "string"], "items": {"type": "string"} } |
Hi, thanks for the great addon.
I found that using an array for key bindings (e.g.,
["cmd:A", "cmd:B"]) was causing errors due to schema validation and implementation logic.I have updated
implementation.jsandschema.jsonto support array-based commands properly.This allows users to execute multiple commands with a single key press (e.g., Mark as Read -> Archive).
Please review the changes. Thanks!