-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Add reflection to the ActionArgs in the settings model #18915
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted
@@ -757,6 +838,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |||
AddAction(*cmd, keys); | |||
} | |||
|
|||
void ActionMap::DeleteUserCommand(const winrt::hstring& cmdID) | |||
{ | |||
_ActionMap.erase(cmdID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ActionMap.erase(cmdID); | |
_ActionMap.erase(cmdID); | |
_changeLog.emplace(IDKey) |
This one I'm iffy on, so I want to discuss here.
Currently, there isn't a place where we're tracking if a user added an ID. In the JSON, the user would be using "id" in two cases for Action Map:
- create a new action in the
"actions"
block (i.e.{"command": "terminalChat", "id": "User.terminalChat"}
)- That's fine? We care about action arg usage and that's already being handled.
- create a key binding in the
"keybindings"
block (i.e.{"id": "User.terminalChat", "keys": "ctrl+?}
)- That's fine too. We care about "keys" usage and that's already being handled.
(related: "id"
is used in the new tab menu, but we're just tracking "action"
there which is sufficient)
Long-term, however, we want _changeLog
to be a way for us to know if the user changed anything. So maybe we do want to apply the code suggestion and update case 1 to add "id"
too? Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is tough because I imagine most users won't be actually adding their own IDs - it will just be autogenerated for them. So distinguishing between us generating an ID for them vs an ID they added or changed is... tricky
src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
…/pabhoj/settings_model_reflection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Really just blocking over the missing SaveSnippet
name in the map (the other two are a question and a suggestion). Nice work!
I'll come back and approve when that SaveSnippet
comment gets resolved. I'll have to come back and approve it anyways haha.
Summary of the Pull Request
Implements reflection to the various ActionArg types in the settings model, which allows these structs to provide information about themselves (i.e. what args they contain and what types they are). This is necessary as a pre-requisite for the Settings Editor to display and modify these arg values.
Detailed Description of the Pull Request / Additional comments
IActionArgs
interface now has additional methods:ActionArgsMagic
have been updated to support the new interfaceActionMap
has been updated to support adding/editing/deleting actions and keybindings from outside the SettingsModelCommand
has been updated to allow setting its values from outside the SettingsModelValidation Steps Performed
Bug bashed in conjunction with #18917
PR Checklist