Problem
Running worktree setup (or any config operation that calls config.save()) collapses multiline hook scripts into a single escaped line.
For example, a manually written config like:
[hooks]
"post:open" = """
#!/usr/bin/env bash
echo "Worktree ready: {{owner}}/{{repo}}#{{issue}} ({{branch}})"
"""
becomes after setup saves:
[hooks]
"post:open" = "#!/usr/bin/env bash\necho \"Worktree ready: {{owner}}/{{repo}}#{{issue}} ({{branch}})\"\n"
Root Cause
src/config/ser.rs — toml_quoted() escapes \n as \\n, always producing a single-line TOML basic string regardless of whether the value contains newlines. The to_toml_with_comments() method uses this for all hook values.
Expected Behavior
When a hook script value contains newlines, it should be written as a TOML multiline literal or multiline basic string so the file remains human-readable and editable, e.g.:
"post:open" = """
#!/usr/bin/env bash
echo "Worktree ready: {{owner}}/{{repo}}#{{issue}} ({{branch}})"
"""
Suggested Fix
In toml_quoted (or in the call site), detect when the value contains \n and emit a TOML multiline basic string ("""...""") instead of a single-line basic string.
Problem
Running
worktree setup(or any config operation that callsconfig.save()) collapses multiline hook scripts into a single escaped line.For example, a manually written config like:
becomes after
setupsaves:Root Cause
src/config/ser.rs—toml_quoted()escapes\nas\\n, always producing a single-line TOML basic string regardless of whether the value contains newlines. Theto_toml_with_comments()method uses this for all hook values.Expected Behavior
When a hook script value contains newlines, it should be written as a TOML multiline literal or multiline basic string so the file remains human-readable and editable, e.g.:
Suggested Fix
In
toml_quoted(or in the call site), detect when the value contains\nand emit a TOML multiline basic string ("""...""") instead of a single-line basic string.