Terminal doesn't support serializing multiple bindings for the same action #3348

Closed
opened 2026-01-30 23:19:15 +00:00 by claunia · 13 comments
Owner

Originally created by @trajano on GitHub (Aug 10, 2019).

AppKeyBindingsSerialization::ToJson iterates over actions and serializes down the first key it can find.


Environment

Microsoft Windows [Version 10.0.18947.1000]
Windows Terminal latest store version

Steps to reproduce

Haven't found a pattern yet.

Expected behavior

My shortcuts which I have defined in https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8 should be kept

Actual behavior

My shortcuts for copy (ctrl+insert) and paste (shift+insert) keep on disappearing.

Originally created by @trajano on GitHub (Aug 10, 2019). `AppKeyBindingsSerialization::ToJson` iterates over _actions_ and serializes down the first key it can find. --- <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Microsoft Windows [Version 10.0.18947.1000] Windows Terminal latest store version ``` # Steps to reproduce Haven't found a pattern yet. # Expected behavior My shortcuts which I have defined in https://gist.github.com/trajano/24f4edccd9a997fad8b4de29ea252cc8 should be kept # Actual behavior My shortcuts for copy (ctrl+insert) and paste (shift+insert) keep on disappearing.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 10, 2019):

This may just be our key deserializer not being broad enough. When it finds a key it cannot read, it discards it. Can you try ins instead of insert?

@DHowett-MSFT commented on GitHub (Aug 10, 2019): This may just be our key deserializer not being broad enough. When it finds a key it cannot read, it discards it. Can you try `ins` instead of `insert`?
Author
Owner

@trajano commented on GitHub (Aug 10, 2019):

ctrl+insert worked correctly and ctrl+ins is not triggering the copy command.

@trajano commented on GitHub (Aug 10, 2019): `ctrl+insert` worked correctly and `ctrl+ins` is not triggering the copy command.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 12, 2019):

Sorry, I can't tell what you're reporting now. ctrl+insert worked correctly, but it is also being deleted from your profiles.json? And it's not working correctly?

@DHowett-MSFT commented on GitHub (Aug 12, 2019): Sorry, I can't tell what you're reporting now. `ctrl+insert` worked correctly, but it is also being deleted from your profiles.json? And it's not working correctly?
Author
Owner

@trajano commented on GitHub (Aug 12, 2019):

The shortcuts that I have defined in the file (as shown in the gist) keep on getting removed and reverted to the original set of shortcuts.

Your suggestion was to use ctrl+ins rather than ctrl-insert but that does not even get recognized by Terminal.

@trajano commented on GitHub (Aug 12, 2019): The shortcuts that I have defined in the file (as shown in the gist) keep on getting removed and reverted to the original set of shortcuts. Your suggestion was to use `ctrl+ins` rather than `ctrl-insert` but that does not even get recognized by Terminal.
Author
Owner

@trajano commented on GitHub (Aug 14, 2019):

It could be related to https://github.com/microsoft/terminal/issues/2411

@trajano commented on GitHub (Aug 14, 2019): It could be related to https://github.com/microsoft/terminal/issues/2411
Author
Owner

@zadjii-msft commented on GitHub (Aug 14, 2019):

Maybe the whole insert thing is a red herring. Let's narrow the problem down.

Can you change any keybindings to a different keys value, and have the settings persist? For example, try changing closePane to:


            { "command" : "closePane", "keys" :  [ "ctrl+w" ] },

If that works, then try setting closePane to "ctrl+insert". Does that persist without reloading? If that persists correctly, does ctrl+insert work to close a tab?

If that works, then lets try setting copy to "ctrl+insert". Does that persist without reloading? If that persists correctly, does ctrl+insert work to copy?

@zadjii-msft commented on GitHub (Aug 14, 2019): Maybe the whole `insert` thing is a red herring. Let's narrow the problem down. Can you change _any_ keybindings to a different `keys` value, and have the settings persist? For example, try changing `closePane` to: ```json { "command" : "closePane", "keys" : [ "ctrl+w" ] }, ``` If that works, then try setting `closePane` to `"ctrl+insert"`. Does that persist without reloading? If that persists correctly, does <kbd>ctrl+insert</kbd> work to close a tab? If that works, then lets try setting `copy` to `"ctrl+insert"`. Does that persist without reloading? If that persists correctly, does <kbd>ctrl+insert</kbd> work to copy?
Author
Owner

@dsafa commented on GitHub (Aug 15, 2019):

I believe it's because there are duplicate commands defined

{
	"command" : "copy",
	"keys" : 
	[
		"ctrl+shift+c"
	]
},
{
	"command" : "copy",
	"keys" : 
	[
		"ctrl+insert"
	]
},

Same for paste. You can test this by duplicating another shortcut and only one will remain.

I'm not sure if its documented if multiple bindings is supposed to be supported? (my searching is failing me). I took a look at AppKeyBindingsSerialization::ToJson and it only seems to iterate once and serialize the first keybinding for a given action from AppKeyBindings::GetKeyBinding. Edit: Nevermind, multiple bindings are supported, its just an issue with serializing them

@dsafa commented on GitHub (Aug 15, 2019): I believe it's because there are duplicate commands defined ```json { "command" : "copy", "keys" : [ "ctrl+shift+c" ] }, { "command" : "copy", "keys" : [ "ctrl+insert" ] }, ``` Same for paste. You can test this by duplicating another shortcut and only one will remain. I'm not sure if its documented if multiple bindings is supposed to be supported? (my searching is failing me). I took a look at `AppKeyBindingsSerialization::ToJson` and it only seems to iterate once and serialize the first keybinding for a given action from `AppKeyBindings::GetKeyBinding`. **Edit:** Nevermind, multiple bindings are supported, its just an issue with serializing them
Author
Owner

@trajano commented on GitHub (Aug 16, 2019):

if that's the case I may as well get rid of the default binding for now since I don't really use it. But I'd like the support for multiple because if other people use my keyboard and they're familiar with the default at least it won't shock them.

@trajano commented on GitHub (Aug 16, 2019): if that's the case I may as well get rid of the default binding for now since I don't really use it. But I'd like the support for multiple because if other people use my keyboard and they're familiar with the default at least it won't shock them.
Author
Owner

@DHowett-MSFT commented on GitHub (Aug 16, 2019):

We definitely thought that multiple bindings for the same action would work. If that's really what's happening, I'm going to repurpose this issue for that.

@DHowett-MSFT commented on GitHub (Aug 16, 2019): We definitely thought that multiple bindings for the same action would work. If that's really what's happening, I'm going to repurpose this issue for that.
Author
Owner

@dsafa commented on GitHub (Aug 16, 2019):

For clarity: The multiple shortcuts will work the first time terminal loads the settings with multiple bindings but not for subsequent restarts.
Heres an issue report for completeness

Environment

Windows version: 10.0.18362.0
Windows Terminal version (if applicable): all

Steps to reproduce

  1. Add multiple shortcuts for the same command to profiles.json
    example 2 copy shortcuts:
{
	"command" : "copy",
	"keys" : 
	[
		"ctrl+shift+c"
	]
},
{
	"command" : "copy",
	"keys" : 
	[
		"ctrl+insert"
	]
}
  1. Start/restart windows terminal.
  2. Try the different key bindings to invoke the command

Expected behavior

All shortcuts defined for the command should work and persist over multiple restarts of terminal.

Actual behavior

The multiple shortcuts defined for the command will only work until the next restart. On subsequent runs, only one of the shortcuts for the command will remain in settings.json.

Details

When the settings are serialized (such as on startup after the settings are loaded), only one shortcut per command is serialized. So the next startup will only have one shortcut.
Relevant functions are AppKeyBindingsSerialization::ToJson and AppKeyBindings::GetKeyBinding.

@dsafa commented on GitHub (Aug 16, 2019): For clarity: The multiple shortcuts will work the first time terminal loads the settings with multiple bindings but not for subsequent restarts. Heres an issue report for completeness # Environment ```none Windows version: 10.0.18362.0 Windows Terminal version (if applicable): all ``` # Steps to reproduce 1. Add multiple shortcuts for the same command to `profiles.json` example 2 copy shortcuts: ```json { "command" : "copy", "keys" : [ "ctrl+shift+c" ] }, { "command" : "copy", "keys" : [ "ctrl+insert" ] } ``` 2. Start/restart windows terminal. 3. Try the different key bindings to invoke the command # Expected behavior All shortcuts defined for the command should work and persist over multiple restarts of terminal. # Actual behavior The multiple shortcuts defined for the command will only work until the next restart. On subsequent runs, only one of the shortcuts for the command will remain in `settings.json`. # Details When the settings are serialized (such as on startup after the settings are loaded), only one shortcut per command is serialized. So the next startup will only have one shortcut. Relevant functions are `AppKeyBindingsSerialization::ToJson` and `AppKeyBindings::GetKeyBinding`.
Author
Owner

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

Moving this out to backlog since we're not planning on serializing any settings until the UI lands.

@DHowett-MSFT commented on GitHub (Jan 28, 2020): Moving this out to backlog since we're not planning on serializing any settings until the UI lands.
Author
Owner

@carlos-zamora commented on GitHub (May 13, 2020):

Moving this out to backlog since we're not planning on serializing any settings until the UI lands.

Moving this into v2 milestone since settings UI is probably something we'll start looking at soon.

@carlos-zamora commented on GitHub (May 13, 2020): > Moving this out to backlog since we're not planning on serializing any settings until the UI lands. Moving this into v2 milestone since settings UI is probably something we'll start looking at soon.
Author
Owner

@zadjii-msft commented on GitHub (Jan 24, 2022):

I'm pretty sure we fixed this some time ago...
image

Probably with the rest of the SUI work.

@zadjii-msft commented on GitHub (Jan 24, 2022): I'm pretty sure we fixed this some time ago... ![image](https://user-images.githubusercontent.com/18356694/150799842-246ec3db-ee12-49a2-a9e3-6d327c686c0a.png) Probably with the rest of the SUI work.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3348