diff options
| author | Jeffrey C. Ollie <jeff@ocjtech.us> | 2025-09-22 19:36:07 -0500 |
|---|---|---|
| committer | Jeffrey C. Ollie <jeff@ocjtech.us> | 2025-09-23 20:44:49 -0500 |
| commit | 5265414a36d9b5ad942ca997adf7348b8d0bd5d4 (patch) | |
| tree | affd164e19e6280bfe3c68a75b9be72049e6dccc /src/cli/CommaSplitter.zig | |
| parent | f97518cc100599186846282457be520fda11f467 (diff) | |
config: smarter parsing in autoParseStruct
Fixes #8849
Previously, the `parseAutoStruct` function that was used to parse
generic structs for the config simply split the input value on commas
without taking into account quoting or escapes. This led to problems
because it was impossible to include a comma in the value of config
entries that were parsed by `parseAutoStruct`. This is particularly
problematic because `ghostty +show-config --default` would produce
output like the following:
```
command-palette-entry = title:Focus Split: Next,description:Focus the next split, if any.,action:goto_split:next
```
Because the `description` contains a comma, Ghostty is unable to
parse this correctly. The value would be split into four parts:
```
title:Focus Split: Next
description:Focus the next split
if any.
action:goto_split:next
```
Instead of three parts:
```
title:Focus Split: Next
description:Focus the next split, if any.
action:goto_split:next
```
Because `parseAutoStruct` simply looked for commas to split on, no
amount of quoting or escaping would allow that to be parsed correctly.
This is fixed by (1) introducing a parser that will split the input
to `parseAutoStruct` into fields while taking into account quotes and
escaping. And (2) changing the `ghostty +show-config` output to put the
values in `command-palette-entry` into quotes so that Ghostty can parse
it's own output.
`parseAutoStruct` will also now parse double quoted values as a Zig
string literal. This makes it easier to embed control codes, whitespace,
and commas in values.
Diffstat (limited to 'src/cli/CommaSplitter.zig')
0 files changed, 0 insertions, 0 deletions
