[PR #2515] [MERGED] Add Cascading User + Default Settings #24972

Open
opened 2026-01-31 09:06:28 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2515
Author: @zadjii-msft
Created: 8/22/2019
Status: Merged
Merged: 9/16/2019
Merged by: @zadjii-msft

Base: masterHead: dev/migrie/f/754-layer-settings


📝 Commits (10+)

  • 858341f Create profiles by layering them
  • 2074ac2 Update test to layer multiple times on the same profile
  • deb135f Add support for layering an array of profiles, but break a couple tests
  • e524ea7 Add a defaults.json to the package
  • 8157fd6 Layer colorschemes
  • 16336bb Layer an array of color schemes
  • 870fed3 Merge remote-tracking branch 'origin/master' into dev/migrie/f/754-layer-settings
  • 22e375d oh no, this was missed with #2481
  • 4e3c3c3 Layer keybindings
  • 2c2fa14 Read settings from defaults.json + profiles.json, layer appropriately

📊 Changes

36 files changed (+2783 additions, -699 deletions)

View changed files

📝 doc/user-docs/UsingJsonSettings.md (+120 -18)
📝 src/cascadia/CascadiaPackage/CascadiaPackage.wapproj (+8 -0)
src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp (+234 -0)
src/cascadia/LocalTests_TerminalApp/JsonTestClass.h (+36 -0)
src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp (+159 -0)
src/cascadia/LocalTests_TerminalApp/ProfileTests.cpp (+296 -0)
📝 src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp (+630 -41)
📝 src/cascadia/LocalTests_TerminalApp/TabTests.cpp (+1 -1)
📝 src/cascadia/LocalTests_TerminalApp/TerminalApp.LocalTests.vcxproj (+5 -1)
📝 src/cascadia/TerminalApp/App.cpp (+1 -2)
📝 src/cascadia/TerminalApp/App.h (+0 -1)
📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+2 -1)
📝 src/cascadia/TerminalApp/AppKeyBindings.cpp (+11 -0)
📝 src/cascadia/TerminalApp/AppKeyBindings.h (+15 -0)
📝 src/cascadia/TerminalApp/AppKeyBindings.idl (+3 -1)
📝 src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp (+59 -31)
src/cascadia/TerminalApp/AppKeyBindingsSerialization.h (+0 -28)
📝 src/cascadia/TerminalApp/CascadiaSettings.cpp (+111 -311)
📝 src/cascadia/TerminalApp/CascadiaSettings.h (+26 -5)
📝 src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp (+261 -71)

...and 16 more files

📄 Description

Summary of the Pull Request

This PR represents the start of the work on Cascading User + default settings, #754.

Cascading settings will be done in two parts:

  • Layered Default+User settings (this PR)
  • Dynamic Profile Generation (#2603).

Until both are done, _neither are going in. The dynamic profiles PR will target this PR when it's ready, but will go in as a separate commit into master.

This PR covers adding one primary feature: the settings are now in two separate files:

  • a static defaults.json that ships with the package (the "default settings")
  • a profiles.json with the user's customizations (the "user settings)

User settings are layered upon the settings in the defaults settings.

References

Other things that might be related here:

  • #1378 - This seems like it's definitely fixed. The default keybindings are much cleaner, and without the save-on-load behavior, the user's keybindings will be left in a good state
  • #1398 - This might have honestly been solved by #2475

PR Checklist

Detailed Description of the Pull Request / Additional comments

  1. We start by taking all of the FromJson functions in Profile, ColorScheme, Globals, etc, and converting them to LayerJson methods. These are effectively the same, with the change that instead of building a new object, they are simply layering the values on top of this object.
  2. Next, we add tests for layering properties like that.
  3. Now, we add a defaults.json to the package. This is the file the users can refer to as our default settings.
  4. We then take that defaults.json and stamp it into an auto generated .h file, so we can use it's data without having to worry about reading it from disk.
  5. We then change the LoadAll function in CascadiaSettings. Now, the function does two loads - one from the defaults, and then a second load from the profiles.json file, layering the settings from each source upon the previous values.
  6. If the profiles.json file doesn't exist, we'll create it from a hardcoded userDefaults.json, which is stamped in similar to how defaults.json is.
  7. We also add support for unbinding keybindings that might exist in the defaults.json, but the user doesn't want to be bound to anything.
  8. We add support for hiding a profile, which is useful if a user doesn't want one of the default profiles to appear in the list of profiles.

TODO:

  • Still need to make Alt+Click work on the settings button
  • Need to write some user documentation on how the new settings model works
  • Fix the pair of tests I broke (re: Duplicate profiles)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2515 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 8/22/2019 **Status:** ✅ Merged **Merged:** 9/16/2019 **Merged by:** [@zadjii-msft](https://github.com/zadjii-msft) **Base:** `master` ← **Head:** `dev/migrie/f/754-layer-settings` --- ### 📝 Commits (10+) - [`858341f`](https://github.com/microsoft/terminal/commit/858341f392c6431775e9beeaae0cd3543ea043eb) Create profiles by layering them - [`2074ac2`](https://github.com/microsoft/terminal/commit/2074ac201b3049b5030fedd7f146fa252f97b872) Update test to layer multiple times on the same profile - [`deb135f`](https://github.com/microsoft/terminal/commit/deb135f50d109b50327bcbbb5340386a3b41b011) Add support for layering an array of profiles, but break a couple tests - [`e524ea7`](https://github.com/microsoft/terminal/commit/e524ea75c29e3675b75d803ce75ec23c23dc25f1) Add a defaults.json to the package - [`8157fd6`](https://github.com/microsoft/terminal/commit/8157fd6195870e950cf86245c5269864d42af7c3) Layer colorschemes - [`16336bb`](https://github.com/microsoft/terminal/commit/16336bb6a52d10e5cdaa21e25536ed521603cc36) Layer an array of color schemes - [`870fed3`](https://github.com/microsoft/terminal/commit/870fed300288ec2943617b7a28050f94dfb65c9b) Merge remote-tracking branch 'origin/master' into dev/migrie/f/754-layer-settings - [`22e375d`](https://github.com/microsoft/terminal/commit/22e375dfbb1dfca0dcb57a06ae4858f29d59a8aa) oh no, this was missed with #2481 - [`4e3c3c3`](https://github.com/microsoft/terminal/commit/4e3c3c3919f62f24c1198507dc8c674c53b33c8a) Layer keybindings - [`2c2fa14`](https://github.com/microsoft/terminal/commit/2c2fa147d690df1903479251bf8eaae46bda77d8) Read settings from defaults.json + profiles.json, layer appropriately ### 📊 Changes **36 files changed** (+2783 additions, -699 deletions) <details> <summary>View changed files</summary> 📝 `doc/user-docs/UsingJsonSettings.md` (+120 -18) 📝 `src/cascadia/CascadiaPackage/CascadiaPackage.wapproj` (+8 -0) ➕ `src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp` (+234 -0) ➕ `src/cascadia/LocalTests_TerminalApp/JsonTestClass.h` (+36 -0) ➕ `src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp` (+159 -0) ➕ `src/cascadia/LocalTests_TerminalApp/ProfileTests.cpp` (+296 -0) 📝 `src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp` (+630 -41) 📝 `src/cascadia/LocalTests_TerminalApp/TabTests.cpp` (+1 -1) 📝 `src/cascadia/LocalTests_TerminalApp/TerminalApp.LocalTests.vcxproj` (+5 -1) 📝 `src/cascadia/TerminalApp/App.cpp` (+1 -2) 📝 `src/cascadia/TerminalApp/App.h` (+0 -1) 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+2 -1) 📝 `src/cascadia/TerminalApp/AppKeyBindings.cpp` (+11 -0) 📝 `src/cascadia/TerminalApp/AppKeyBindings.h` (+15 -0) 📝 `src/cascadia/TerminalApp/AppKeyBindings.idl` (+3 -1) 📝 `src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp` (+59 -31) ➖ `src/cascadia/TerminalApp/AppKeyBindingsSerialization.h` (+0 -28) 📝 `src/cascadia/TerminalApp/CascadiaSettings.cpp` (+111 -311) 📝 `src/cascadia/TerminalApp/CascadiaSettings.h` (+26 -5) 📝 `src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp` (+261 -71) _...and 16 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR represents the start of the work on Cascading User + default settings, #754. Cascading settings will be done in two parts: * [ ] Layered Default+User settings (this PR) * [ ] Dynamic Profile Generation (#2603). Until _both_ are done, _neither are going in. The dynamic profiles PR will target this PR when it's ready, but will go in as a separate commit into master. This PR covers adding one primary feature: the settings are now in two separate files: * a static `defaults.json` that ships with the package (the "default settings") * a `profiles.json` with the user's customizations (the "user settings) User settings are _layered_ upon the settings in the defaults settings. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References Other things that might be related here: * #1378 - This seems like it's definitely fixed. The default keybindings are _much_ cleaner, and without the save-on-load behavior, the user's keybindings will be left in a good state * #1398 - This might have honestly been solved by #2475 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #754 * [x] Closes #1378 * [x] Closes #2566 * [x] I work here * [x] Tests added/passed * [x] Requires documentation to be updated - it **ABSOLUTELY DOES** <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments 1. We start by taking all of the `FromJson` functions in Profile, ColorScheme, Globals, etc, and converting them to `LayerJson` methods. These are effectively the same, with the change that instead of building a new object, they are simply layering the values on top of `this` object. 2. Next, we add tests for layering properties like that. 3. Now, we add a `defaults.json` to the package. This is the file the users can refer to as our default settings. 4. We then take that `defaults.json` and stamp it into an auto generated `.h` file, so we can use it's data without having to worry about reading it from disk. 5. We then change the `LoadAll` function in `CascadiaSettings`. Now, the function does two loads - one from the defaults, and then a second load from the `profiles.json` file, layering the settings from each source upon the previous values. 6. If the `profiles.json` file doesn't exist, we'll create it from a hardcoded `userDefaults.json`, which is stamped in similar to how `defaults.json` is. 7. We also add support for _unbinding_ keybindings that might exist in the `defaults.json`, but the user doesn't want to be bound to anything. 8. We add support for _hiding_ a profile, which is useful if a user doesn't want one of the default profiles to appear in the list of profiles. ## TODO: * [x] Still need to make Alt+Click work on the settings button * [x] Need to write some user documentation on how the new settings model works * [x] Fix the pair of tests I broke (re: Duplicate profiles) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:06:28 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24972