Skip to content

Trim trailing whitespace when writing settings.json#19834

Closed
ThanhNguyxn wants to merge 1 commit intomicrosoft:mainfrom
ThanhNguyxn:fix/10887-trailing-whitespace
Closed

Trim trailing whitespace when writing settings.json#19834
ThanhNguyxn wants to merge 1 commit intomicrosoft:mainfrom
ThanhNguyxn:fix/10887-trailing-whitespace

Conversation

@ThanhNguyxn
Copy link

Summary of the Pull Request

This patch strips trailing spaces and tabs from each serialized line before writing settings.json. It keeps current JSON formatting options intact while preventing whitespace-only churn from Settings UI saves.

References and Relevant Issues

Closes #10887

Detailed Description of the Pull Request / Additional comments

  • Added a small line-by-line sanitizer in CascadiaSettings::WriteSettingsToDisk.
  • Applied the sanitizer to the serialized string returned by Json::writeString(...) before _writeSettingsToDisk(...) is called.
  • Preserves line endings and only removes trailing horizontal whitespace at end-of-line.

Validation Steps Performed

  • Verified issue triage constraints:
  • Ran git diff --check to confirm no trailing whitespace/conflict markers in this patch.
  • Attempted LSP diagnostics, but local environment cannot start LSP on Windows+Bun 1.3.5 (known toolchain limitation).

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Area-Settings Issues related to settings and customizability, for console or terminal Priority-3 A description (P3) Product-Terminal The new Windows Terminal. labels Feb 6, 2026
@ThanhNguyxn
Copy link
Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 19834 in repo microsoft/terminal

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

I appreciate your eagerness to contribute, but I would much rather have somebody contribute a fix to our upstream JSON serialization library (tracked in open-source-parsers/jsoncpp#1154) or manage to import that pull request as a patch rather than introduce a hundred lines of our own string processing code to resolve what is--effectively--a visual glitch somebody just doesn't like. :)

@DHowett DHowett closed this Feb 6, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 6, 2026
@DHowett
Copy link
Member

DHowett commented Feb 6, 2026

I've done that over here: #19836

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Settings Issues related to settings and customizability, for console or terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Priority-3 A description (P3) Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings editor saves settings.json lines with trailing whitespace

2 participants