Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ActionMap and Command to use ActionIDs #17162

Merged
merged 84 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
90627b3
add origin tag
PankajBhojwani Mar 5, 2024
9dff28f
update calls in tests
PankajBhojwani Mar 5, 2024
8bcbd0b
fix tests
PankajBhojwani Mar 5, 2024
052d063
ah one of the tests uses this
PankajBhojwani Mar 5, 2024
8cc82de
generated
PankajBhojwani Mar 5, 2024
642d0ab
inbox makes more sense
PankajBhojwani Mar 5, 2024
66fe08f
default ids
PankajBhojwani Mar 7, 2024
2bb1b6c
conflict
PankajBhojwani Mar 19, 2024
be193b2
merge origin
PankajBhojwani Mar 19, 2024
db528c9
generate IDs for user commands
PankajBhojwani Mar 26, 2024
7c907fe
nits
PankajBhojwani Mar 26, 2024
b43191d
spacing
PankajBhojwani Mar 26, 2024
2093660
line
PankajBhojwani Mar 26, 2024
6c32539
string of numbers is unsightly but it works
PankajBhojwani Mar 27, 2024
eccd87f
update comment
PankajBhojwani Mar 27, 2024
44510dc
move id generation to fixupusersettings
PankajBhojwani Mar 28, 2024
10d1fc8
this way is better
PankajBhojwani Mar 28, 2024
71bf90f
even better, also get the ID from json
PankajBhojwani Mar 28, 2024
d57c7a1
move this
PankajBhojwani Mar 28, 2024
5c2307c
fix test
PankajBhojwani Mar 28, 2024
9fc6972
add tests
PankajBhojwani Mar 29, 2024
dca7df5
excess line
PankajBhojwani Mar 29, 2024
dd25ed7
change tests
PankajBhojwani Apr 1, 2024
6e293a5
Everytime
PankajBhojwani Apr 1, 2024
af2d22f
defaults conflict
PankajBhojwani Apr 11, 2024
bdf42c2
first round of nits
PankajBhojwani Apr 11, 2024
12f3aa9
truncate and hex, debug assert
PankajBhojwani Apr 12, 2024
aa49212
null check
PankajBhojwani Apr 12, 2024
5ee630e
fmt is smart
PankajBhojwani Apr 12, 2024
360b92e
fmt_compile, fix test
PankajBhojwani Apr 17, 2024
5e70911
remove 0
PankajBhojwani Apr 17, 2024
ca3eb87
rename and comment
PankajBhojwani Apr 17, 2024
85933e2
midpoint
PankajBhojwani Apr 23, 2024
c134402
about to test stage 1
PankajBhojwani Apr 24, 2024
22ab936
works??
PankajBhojwani Apr 24, 2024
0a3e17e
edge cases
PankajBhojwani Apr 24, 2024
e28d478
some todos for later
PankajBhojwani Apr 24, 2024
f425746
remove keysmap
PankajBhojwani Apr 24, 2024
d0938e2
ugly way to make sure we fixup
PankajBhojwani Apr 25, 2024
12a61c5
shows up in sui and all keybindings work
PankajBhojwani Apr 26, 2024
f1633e0
overwritten IDs and overwritten keychords show up properly in the SUI
PankajBhojwani Apr 26, 2024
ddfac90
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Apr 26, 2024
3e7ab38
sui works?
PankajBhojwani Apr 26, 2024
ae16a5e
started stage 3
PankajBhojwani Apr 26, 2024
dc874c3
rename to special/standard
PankajBhojwani Apr 27, 2024
936afd6
_getactionbyid no longer returns optional
PankajBhojwani Apr 27, 2024
b3e9c26
remove check for invalid
PankajBhojwani Apr 27, 2024
5a1b822
reimplement populating all known keybindings
PankajBhojwani Apr 30, 2024
c51558f
unmark these
PankajBhojwani Apr 30, 2024
754bf04
mark gh todo
PankajBhojwani Apr 30, 2024
2f1d8d2
update defaults
PankajBhojwani Apr 30, 2024
2b4aeb2
don't check for special in standard
PankajBhojwani Apr 30, 2024
e62dfa2
some comments
PankajBhojwani Apr 30, 2024
e725f1e
resolve conflict
PankajBhojwani Apr 30, 2024
db00b90
spelling things
PankajBhojwani Apr 30, 2024
3d92f27
format
PankajBhojwani Apr 30, 2024
428821b
remove _idwasgenerated
PankajBhojwani Apr 30, 2024
6437b9f
fix user defaults file
PankajBhojwani Apr 30, 2024
4c744e6
misc
PankajBhojwani Apr 30, 2024
ca4015f
only one tojson
PankajBhojwani Apr 30, 2024
45cfcd6
just add duplicate pane auto to defaults
PankajBhojwani Apr 30, 2024
3c6015d
remove _getcumulativeactions
PankajBhojwani Apr 30, 2024
c2c75c8
bandaid temporary fix for name
PankajBhojwani May 1, 2024
3e601f5
better if
PankajBhojwani May 1, 2024
cdb907d
mark todo
PankajBhojwani May 1, 2024
f35bf20
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani May 1, 2024
2b16acd
check for name, fix some tests
PankajBhojwani May 1, 2024
193e573
fix remaining tests
PankajBhojwani May 2, 2024
0480d65
this is better
PankajBhojwani May 2, 2024
02a1e37
correct GH todo
PankajBhojwani May 2, 2024
80fc299
some new tests
PankajBhojwani May 3, 2024
ebc03e9
another test
PankajBhojwani May 3, 2024
ccf1cc9
nits
PankajBhojwani May 3, 2024
7793c5c
schema
PankajBhojwani May 3, 2024
abef25d
move this to header
PankajBhojwani May 3, 2024
4d35c14
schema conflict
PankajBhojwani May 3, 2024
3e31bda
generate here instead
PankajBhojwani May 6, 2024
14d83b5
delete user actions that are identical to inbox actions
PankajBhojwani May 6, 2024
6c6dd46
leonard comments
PankajBhojwani May 20, 2024
b88a8c5
eraseif
PankajBhojwani May 30, 2024
9703815
nits n fixes
PankajBhojwani May 31, 2024
a80316d
1 more test
PankajBhojwani May 31, 2024
625753c
x86 hash
PankajBhojwani Jun 1, 2024
406312f
fix loops
PankajBhojwani Jun 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 43 additions & 20 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@
]
}
},
"Keybinding": {
"FullCommand": {
"additionalProperties": false,
"properties": {
"command": {
Expand Down Expand Up @@ -2186,21 +2186,6 @@
}
]
},
"keys": {
"description": "Defines the key combinations used to call the command. It must be composed of...\n -any number of modifiers (ctrl/alt/shift)\n -a non-modifier key",
"oneOf": [
{
"$ref": "#/$defs/KeyChordSegment"
},
{
"items": {
"$ref": "#/$defs/KeyChordSegment"
},
"minItems": 1,
"type": "array"
}
]
},
"icon": {
"$ref": "#/$defs/Icon"
},
Expand Down Expand Up @@ -2235,10 +2220,10 @@
"type": "object",
"properties": {
"command": {
"$ref": "#/$defs/Keybinding/properties/command"
"$ref": "#/$defs/FullCommand/properties/command"
},
"name": {
"$ref": "#/$defs/Keybinding/properties/name"
"$ref": "#/$defs/FullCommand/properties/name"
}
}
},
Expand All @@ -2261,6 +2246,44 @@
],
"type": "object"
},
"Keybinding": {
"additionalProperties": false,
"properties": {
"id": {
"description": "The ID of the command this keybinding should execute.",
"type": "string"
},
"keys": {
"description": "Defines the key combinations used to call the command. It must be composed of...\n -any number of modifiers (ctrl/alt/shift)\n -a non-modifier key",
"oneOf": [
{
"$ref": "#/$defs/KeyChordSegment"
},
{
"items": {
"$ref": "#/$defs/KeyChordSegment"
},
"minItems": 1,
"type": "array"
}
]
}
},
"anyOf": [
{
"required": [
"keys",
"id"
]
},
{
"required": [
"keys"
]
}
],
"type": "object"
},
"Globals": {
"additionalProperties": true,
"description": "Properties that affect the entire window, regardless of the profile settings.",
Expand Down Expand Up @@ -2464,12 +2487,12 @@
"actions": {
"description": "Properties are specific to each custom action.",
"items": {
"$ref": "#/$defs/Keybinding"
"$ref": "#/$defs/FullCommand"
},
"type": "array"
},
"keybindings": {
"description": "[deprecated] Use actions instead.",
"description": "A list of keychords bound to action IDs",
"deprecated": true,
"items": {
"$ref": "#/$defs/Keybinding"
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalApp/TabBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ namespace winrt::TerminalApp::implementation
// - <none>
void TabBase::_UpdateSwitchToTabKeyChord()
{
const auto keyChord = _actionMap ? _actionMap.GetKeyBindingForAction(ShortcutAction::SwitchToTab, SwitchToTabArgs{ _TabViewIndex }) : nullptr;
const auto id = fmt::format(FMT_COMPILE(L"Terminal.SwitchToTab{}"), _TabViewIndex);
const auto keyChord{ _actionMap.GetKeyBindingForAction(id) };
const auto keyChordText = keyChord ? KeyChordSerialization::ToString(keyChord) : L"";

if (_keyChord == keyChordText)
Expand Down
7 changes: 4 additions & 3 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ namespace winrt::TerminalApp::implementation
newTabFlyout.Items().Append(settingsItem);

auto actionMap = _settings.ActionMap();
const auto settingsKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::OpenSettings, OpenSettingsArgs{ SettingsTarget::SettingsUI }) };
const auto settingsKeyChord{ actionMap.GetKeyBindingForAction(L"Terminal.OpenSettingsUI") };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i really like how clean this feels now

if (settingsKeyChord)
{
_SetAcceleratorForMenuItem(settingsItem, settingsKeyChord);
Expand All @@ -848,7 +848,7 @@ namespace winrt::TerminalApp::implementation
commandPaletteFlyout.Click({ this, &TerminalPage::_CommandPaletteButtonOnClick });
newTabFlyout.Items().Append(commandPaletteFlyout);

const auto commandPaletteKeyChord{ actionMap.GetKeyBindingForAction(ShortcutAction::ToggleCommandPalette) };
const auto commandPaletteKeyChord{ actionMap.GetKeyBindingForAction(L"Terminal.ToggleCommandPalette") };
if (commandPaletteKeyChord)
{
_SetAcceleratorForMenuItem(commandPaletteFlyout, commandPaletteKeyChord);
Expand Down Expand Up @@ -1023,7 +1023,8 @@ namespace winrt::TerminalApp::implementation
// NewTab(ProfileIndex=N) action
NewTerminalArgs newTerminalArgs{ profileIndex };
NewTabArgs newTabArgs{ newTerminalArgs };
auto profileKeyChord{ _settings.ActionMap().GetKeyBindingForAction(ShortcutAction::NewTab, newTabArgs) };
const auto id = fmt::format(FMT_COMPILE(L"Terminal.OpenNewTabProfile{}"), profileIndex);
const auto profileKeyChord{ _settings.ActionMap().GetKeyBindingForAction(id) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There 100% is a issue right now for "I rebound keys for new tab profile N, but the dropdown still has the old ones" and I'm guessing this will solve that (because people can rebind the key for the literal Terminal.OpenNewTabProfile5 rather than just making a new Command for it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#13943 I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this fixes that! Also fixes it in the cmd palette

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PankajBhojwani should this PR close that bug?


// make sure we find one to display
if (profileKeyChord)
Expand Down
Loading
Loading