Settings editor saves settings.json lines with trailing whitespace #14804

Open
opened 2026-01-31 04:19:57 +00:00 by claunia · 9 comments
Owner

Originally created by @mrjoel on GitHub (Aug 6, 2021).

Windows Terminal version (or Windows build number)

1.9.1942.0

Other Software

No response

Steps to reproduce

I have my settings.json tracked in a dotfiles git repo. Recently (now that settings UI is available) I've noticed that the settings.json is save with a trailing space after a name. This appears to be the case when the name is an array or object whose contents continue onto the next line (i.e. the space after the name is always added without considering whether a string value or array/object value will follow.

Expected Behavior

Lines are trimmed when saving

Actual Behavior

Extra spaces are left behind for entries which span multiple lines.

Originally created by @mrjoel on GitHub (Aug 6, 2021). ### Windows Terminal version (or Windows build number) 1.9.1942.0 ### Other Software _No response_ ### Steps to reproduce I have my settings.json tracked in a dotfiles git repo. Recently (now that settings UI is available) I've noticed that the settings.json is save with a trailing space after a name. This appears to be the case when the name is an array or object whose contents continue onto the next line (i.e. the space after the name is always added without considering whether a string value or array/object value will follow. ### Expected Behavior Lines are trimmed when saving ### Actual Behavior Extra spaces are left behind for entries which span multiple lines.
Author
Owner

@zadjii-msft commented on GitHub (Aug 10, 2021):

Can you give a specific example? I think I'm having a hard time trying to mentally picture what's wrong here.

@zadjii-msft commented on GitHub (Aug 10, 2021): Can you give a specific example? I think I'm having a hard time trying to mentally picture what's wrong here.
Author
Owner

@mrjoel commented on GitHub (Aug 11, 2021):

Sure, the specific cases where I see this is happening on my settings.json are listed below, where an extra trailing whitespace character is added.

  • .actions[].command
  • .profiles
  • .profiles.defaults
  • .profiles.list
  • .profiles.schemes

For all of these cases the space is added after the name and colon, but before the value is added, which happens to be on the next line. Instead, I'd expect either to trim each string, or better to use the context to only add the space separator if the next character to be added is not a newline. I haven't taken a look at the code to see how it's handled, but it's curious that .actions is not written with the trailing space, perhaps it gets special handling?

For the case of .actions[].command, what is actually emitted is:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions":
    [
        {
            "command": "find", //mrjoel: note that string values on single line are fine, but object values later are not
            "keys": "ctrl+shift+f"
        },
        {
            "command":␣ // mrjoel: '␣' visually represents literal space character here
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],

What is expected is below, note the lack of trailing space (fake depicted as '␣' to be easier to visualize in the diff).

-            "command":␣
+            "command":
@mrjoel commented on GitHub (Aug 11, 2021): Sure, the specific cases where I see this is happening on my `settings.json` are listed below, where an extra trailing whitespace character is added. * `.actions[].command` * `.profiles` * `.profiles.defaults` * `.profiles.list` * `.profiles.schemes` For all of these cases the space is added after the name and colon, but before the value is added, which happens to be on the next line. Instead, I'd expect either to trim each string, or better to use the context to only add the space separator if the next character to be added is not a newline. I haven't taken a look at the code to see how it's handled, but it's curious that `.actions` is not written with the trailing space, perhaps it gets special handling? For the case of `.actions[].command`, what is actually emitted is: ``` { "$schema": "https://aka.ms/terminal-profiles-schema", "actions": [ { "command": "find", //mrjoel: note that string values on single line are fine, but object values later are not "keys": "ctrl+shift+f" }, { "command":␣ // mrjoel: '␣' visually represents literal space character here { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" } ], ``` What is expected is below, note the lack of trailing space (fake depicted as '␣' to be easier to visualize in the diff). ``` - "command":␣ + "command": ```
Author
Owner

@zadjii-msft commented on GitHub (Feb 17, 2022):

these docs for jsoncpp are relevant. IIRC the flag was enableYAMLCompatibility. I could have swore we had this, even some time after #2515

@zadjii-msft commented on GitHub (Feb 17, 2022): [these docs for jsoncpp](http://open-source-parsers.github.io/jsoncpp-docs/doxygen/class_json_1_1_stream_writer_builder.html#a79bdf2e639a52f4e758c0b95bd1d3423) are relevant. IIRC the flag was `enableYAMLCompatibility`. I could have swore we had this, even some time after #2515
Author
Owner

@networkhermit commented on GitHub (Mar 23, 2024):

these docs for jsoncpp are relevant. IIRC the flag was enableYAMLCompatibility. I could have swore we had this, even some time after #2515

@zadjii-msft Hello. Does it suggest that it's an upstream issue? This issue still exists in Windows Terminal Version: 1.19.10573.0. Renaming settings.json and let the WT recreate a default json file have trailing whitespaces too.

@networkhermit commented on GitHub (Mar 23, 2024): > [these docs for jsoncpp](http://open-source-parsers.github.io/jsoncpp-docs/doxygen/class_json_1_1_stream_writer_builder.html#a79bdf2e639a52f4e758c0b95bd1d3423) are relevant. IIRC the flag was `enableYAMLCompatibility`. I could have swore we had this, even some time after #2515 @zadjii-msft Hello. Does it suggest that it's an upstream issue? This issue still exists in Windows Terminal Version: 1.19.10573.0. Renaming settings.json and let the WT recreate a default json file have trailing whitespaces too.
Author
Owner

@zadjii-msft commented on GitHub (Apr 1, 2024):

I'm not sure! Someone would have to dig into the codebase and make sure we're setting that whenever we're saving the settings. If we are, then yea, I'd bet it's an upstream issue.

@zadjii-msft commented on GitHub (Apr 1, 2024): I'm not sure! Someone would have to dig into the codebase and make sure we're setting that whenever we're saving the settings. If we are, then yea, I'd bet it's an upstream issue.
Author
Owner

@fallenwood commented on GitHub (Jun 3, 2024):

these docs for jsoncpp are relevant. IIRC the flag was enableYAMLCompatibility. I could have swore we had this, even some time after #2515

@zadjii-msft Hello. Does it suggest that it's an upstream issue? This issue still exists in Windows Terminal Version: 1.19.10573.0. Renaming settings.json and let the WT recreate a default json file have trailing whitespaces too.

Looks like a known upstream issue at jsoncpp https://github.com/open-source-parsers/jsoncpp/pull/1154

@fallenwood commented on GitHub (Jun 3, 2024): > > [these docs for jsoncpp](http://open-source-parsers.github.io/jsoncpp-docs/doxygen/class_json_1_1_stream_writer_builder.html#a79bdf2e639a52f4e758c0b95bd1d3423) are relevant. IIRC the flag was `enableYAMLCompatibility`. I could have swore we had this, even some time after #2515 > > @zadjii-msft Hello. Does it suggest that it's an upstream issue? This issue still exists in Windows Terminal Version: 1.19.10573.0. Renaming settings.json and let the WT recreate a default json file have trailing whitespaces too. Looks like a known upstream issue at jsoncpp https://github.com/open-source-parsers/jsoncpp/pull/1154
Author
Owner

@minigithubo commented on GitHub (Sep 13, 2025):

Hi, I'd like to work on this issue. Could you please assign it to me?

@minigithubo commented on GitHub (Sep 13, 2025): Hi, I'd like to work on this issue. Could you please assign it to me?
Author
Owner

@Retr0-XD commented on GitHub (Nov 9, 2025):

I'd like tho work on this issue , can you please assign me

@Retr0-XD commented on GitHub (Nov 9, 2025): I'd like tho work on this issue , can you please assign me
Author
Owner

@shivam-dhir commented on GitHub (Jan 22, 2026):

Hi, I would love to work on this issue

@shivam-dhir commented on GitHub (Jan 22, 2026): Hi, I would love to work on this issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14804