Display a warning when a user tries to bind an action to multiple keys in a single chord #5952

Closed
opened 2026-01-31 00:26:20 +00:00 by claunia · 2 comments
Owner

Originally created by @angelog0 on GitHub (Jan 15, 2020).

After upgrading to WT 0.8, I added this to my profile.json:

"keybindings":
    [
        // "index": 1 ==> "Ubuntu"
        { "keys": ["ctrl+2+plus"],
          "command": {"action": "splitPane", "split": "vertical", "index": 1}
        },
        { "keys": ["ctrl+2+-"],
          "command": {"action": "splitPane", "split": "horizontal", "index": 1}
        }//,
        // "index": 2 ==> "CMD"
        // { "keys": ["ctrl+3+plus"],
        //   "command": {"action": "splitPane", "split": "vertical", "index": 2}
        // },
        // { "keys": ["ctrl+3+-"],
        //   "command": {"action": "splitPane", "split": "horizontal", "index": 2}
        // }
    ]

and it works as expected: profile index 0 is MSYS2 and index 1 is Ubuntu, so ctrl+2+... can split current profile calling Ubuntu.

If I uncomment the other lines (index 2 for CMD), both ctrl+2+... and ctrl+3+... open CMD profile. In short adding similar lines for other profile, always open the last profile and not what they should open...

I wonder what is wrong with those lines.. maybe i have misunderstood? Thanks...

Originally created by @angelog0 on GitHub (Jan 15, 2020). After upgrading to WT 0.8, I added this to my `profile.json`: ``` "keybindings": [ // "index": 1 ==> "Ubuntu" { "keys": ["ctrl+2+plus"], "command": {"action": "splitPane", "split": "vertical", "index": 1} }, { "keys": ["ctrl+2+-"], "command": {"action": "splitPane", "split": "horizontal", "index": 1} }//, // "index": 2 ==> "CMD" // { "keys": ["ctrl+3+plus"], // "command": {"action": "splitPane", "split": "vertical", "index": 2} // }, // { "keys": ["ctrl+3+-"], // "command": {"action": "splitPane", "split": "horizontal", "index": 2} // } ] ``` and it works as expected: profile `index 0` is MSYS2 and `index 1` is Ubuntu, so `ctrl+2+...` can split current profile calling Ubuntu. If I uncomment the other lines (`index 2` for CMD), both `ctrl+2+...` and `ctrl+3+...` open CMD profile. In short adding similar lines for other profile, always open the last profile and not what they should open... I wonder what is wrong with those lines.. maybe i have misunderstood? Thanks...
Author
Owner

@zadjii-msft commented on GitHub (Jan 15, 2020):

Oh we should probably display some sort of warning in this case. You can't really add keybindings with multiple keys like that. You can have any combination of Ctrl, Alt and Shift, but only one actual key like 3 or +. I bet as we're deserializing this, we're finding the 3, setting the Vkey to 3, then finding the + and resetting the vkey to +, effectively overriding the other binding like it.

We should be able to catch this at parse time and display a warning to the user.

@zadjii-msft commented on GitHub (Jan 15, 2020): Oh we should probably display some sort of warning in this case. You can't really add keybindings with multiple _keys_ like that. You can have any combination of <kbd>Ctrl</kbd>, <kbd>Alt</kbd> and <kbd>Shift</kbd>, but only one actual key like <kbd>3</kbd> or <kbd>+</kbd>. I bet as we're deserializing this, we're finding the <kbd>3</kbd>, setting the `Vkey` to `3`, then finding the <kbd>+</kbd> and resetting the vkey to `+`, effectively overriding the other binding like it. We should be able to catch this at parse time and display a warning to the user.
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 16, 2020):

We should definitely warn about this, but the feature you'll eventually want is #1334. That one's not slated for 1.0.

@DHowett-MSFT commented on GitHub (Jan 16, 2020): We should definitely warn about this, but the feature you'll eventually want is #1334. That one's not slated for 1.0.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5952