[PR #12906] [MERGED] Fix profile commandlines being overwritten by profile.defaults #29290

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12906
Author: @lhecker
Created: 4/14/2022
Status: Merged
Merged: 4/18/2022
Merged by: @undefined

Base: mainHead: dev/lhecker/12842-path-fixup


📝 Commits (2)

  • 5f0c83e Fix profile commandlines being overwritten by profile.defaults
  • 57d4e88 Address feedback

📊 Changes

4 files changed (+89 additions, -43 deletions)

View changed files

📝 src/cascadia/LocalTests_SettingsModel/ProfileTests.cpp (+33 -22)
📝 src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp (+0 -1)
📝 src/cascadia/TerminalSettingsModel/CascadiaSettings.h (+1 -1)
📝 src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp (+55 -19)

📄 Description

#12149 introduced a bug where ClearCommandline() is called on any user
profile containing the non-canonical strings "cmd.exe" or "powershell.exe"
in the "commandline" field. If you happen to have set the "commandline"
field in your profiles.defaults, this will cause these user profiles
to adopt the base layer command-line instead of the defaults layer one.

This commit fixes the issue, by checking the command-line after the call
to ClearCommandline() and ensuring it's the expected string.

Additionally this moves the migration logic to SettingsLoader as this allows
us to write the fixed settings to disk, if any fixed had to be applied.

PR Checklist

Validation Steps Performed

  • The modified unit test fails without these changes
  • The modified unit test succeeds with these changes
  • Setting profiles.defaults.commandline to "pwsh.exe" and setting
    my "...\powershell.exe" profile to use just "powershell.exe" as
    the commandline, doesn't cause it to use "pwsh.exe"
    The fixed settings are written to settings.json

🔄 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/12906 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 4/14/2022 **Status:** ✅ Merged **Merged:** 4/18/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/lhecker/12842-path-fixup` --- ### 📝 Commits (2) - [`5f0c83e`](https://github.com/microsoft/terminal/commit/5f0c83ebf7d24f7de6ca4d3f63a1db40ed127c2e) Fix profile commandlines being overwritten by profile.defaults - [`57d4e88`](https://github.com/microsoft/terminal/commit/57d4e881640c98a3846e7e96347b7dd4624d5f1f) Address feedback ### 📊 Changes **4 files changed** (+89 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/LocalTests_SettingsModel/ProfileTests.cpp` (+33 -22) 📝 `src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp` (+0 -1) 📝 `src/cascadia/TerminalSettingsModel/CascadiaSettings.h` (+1 -1) 📝 `src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp` (+55 -19) </details> ### 📄 Description #12149 introduced a bug where `ClearCommandline()` is called on any user profile containing the non-canonical strings "cmd.exe" or "powershell.exe" in the "commandline" field. If you happen to have set the "commandline" field in your `profiles.defaults`, this will cause these user profiles to adopt the base layer command-line instead of the defaults layer one. This commit fixes the issue, by checking the command-line after the call to `ClearCommandline()` and ensuring it's the expected string. Additionally this moves the migration logic to `SettingsLoader` as this allows us to write the fixed settings to disk, if any fixed had to be applied. ## PR Checklist * [x] Closes #12842 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * The modified unit test fails without these changes ✅ * The modified unit test succeeds with these changes ✅ * Setting `profiles.defaults.commandline` to "pwsh.exe" and setting my "...\\powershell.exe" profile to use just "powershell.exe" as the `commandline`, doesn't cause it to use "pwsh.exe" ✅ The fixed settings are written to settings.json ✅ --- <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:34:02 +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#29290