-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Add a schema reference to the userDefaults and patch one into user data #2803
Conversation
@@ -36,6 +37,8 @@ static constexpr std::string_view DisabledProfileSourcesKey{ "disabledProfileSou | |||
|
|||
static constexpr std::string_view Utf8Bom{ u8"\uFEFF" }; | |||
static constexpr std::string_view DefaultProfilesIndentation{ " " }; | |||
static constexpr std::string_view SettingsSchemaFragment{ "\n" | |||
R"( "$schema": "https://aka.ms/terminal-profiles-schema",)" }; |
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.
My regex monstrosity is alive!
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.
you calling out this line taught me that we will almost certainly corrupt a user's profile if we hardcode the ,
here. More thought is required. 😁
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 seems reasonable. Scary, but reasonable.
I'd always love more tests, but I also like shipping...
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.
I owe tests on this, but we don't seem to have any patching tests anywhere. I'm going to defer that to work on #2805. |
🎉 Handy links: |
Summary of the Pull Request
This pull request both adds a schema to the default JSON file written out for the user and adds code to patch a
$schema
into existing user settings.References
#2704
PR Checklist
Detailed Description of the Pull Request / Additional comments
We have to re-parse the settings string after every patch, because there's a chance the object offsets have moved around on us. Alternatively, we could always patch from the bottom up. That approach seems more fragile, even if it's technically faster.
Validation Steps Performed
The tests probably fail, but I tried it locally against my settings file :P