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

Add a schema reference to the userDefaults and patch one into user data #2803

Merged
merged 2 commits into from
Sep 19, 2019

Conversation

DHowett-MSFT
Copy link
Contributor

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

  • Tests added/passed/updated
  • I've discussed this with core contributors already.

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

@@ -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",)" };
Copy link
Collaborator

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!

Copy link
Contributor Author

@DHowett-MSFT DHowett-MSFT Sep 18, 2019

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. 😁

Copy link
Member

@zadjii-msft zadjii-msft left a 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...

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

:shipit:

@DHowett-MSFT
Copy link
Contributor Author

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.

@DHowett-MSFT DHowett-MSFT merged commit 5a57c5a into master Sep 19, 2019
@DHowett-MSFT DHowett-MSFT deleted the dev/duhowett/schematize branch September 19, 2019 01:37
@ghost
Copy link

ghost commented Sep 24, 2019

🎉Windows Terminal Preview v0.5.2661.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants