Area-SettingsHelp WantedIssue-FeatureProduct-Terminal
倉庫指標
- Star
- (35,764 star)
- PR 合併指標
- (平均合併 27天 19小時) (30 天內合併 24 個 PR)
描述
Currently, we only support pressing a single key+modifiers to activate a keybinding action.
However, many text editors support "key chords" where the chord is a combination of multiple keys pressed in sequence. For example, in Visual Studio, the default keybinding for "Comment Code" is the chord [ctrl+c, ctrl+k].
We've already prepared for serializing these chords in the array of keybindings, but we don't support more than one key at a time. We'd have somehow check if a key is the start of a chord, and only dispatch the action when all keys for the chord have been pressed.
Lots of questions:
- What happens if an action is bound to
[ctrl+c, ctrl+k]and another is bound to[ctrl+c]? - If the first key of a chord is pressed, but the second key isn't bound to an action, should we write both keys to the input?
- If the first key of a chord is pressed, but then nothing is pressed for a long time, should we time out?
- What's the best way of finding the right keybinding for a chord?
- Iterating over all of them when a key is pressed, until the chord is dispatched seems awful (but trivial to do).
- Maybe we could build a tree of keychords, or a list of trees?
- My CS542 senses are tingling and suggesting that this might be the case to use a state machine.
- Is a state machine really different than a tree in this case?