settings_json: Locate a key by its own range, not by scanning quotes (#62949)
`replace_value_in_json_text` spelled a newly inserted key with
hand-written quotes, so a key carrying a `"` or a `\` produced invalid
JSON. The removal and rename paths then could not find such a key again:
both walked backwards to the nearest raw `"`, which lands inside an
escape, and ate the neighbouring entry while leaving JSON that still
parses.
The parser already hands back the key's byte range, so the three sites
use it, and serde for the spelling, the way key lookup and the
nested-construction path always did.
Worth knowing beyond the escaping: `update_value_in_json_text` pushes
every map key into the key path verbatim, so any settings map whose keys
are not authored by hand reaches this. Most are typed by the user, but
`favorite_config_option_values` is keyed by a `SessionConfigId` that an
ACP agent supplies over the protocol.
Tests cover insertion into a single-line and a multi-line object,
removal and rename, all with a key carrying a quote and a backslash.
Release Notes:
- Fixed a settings key containing a quote or a backslash corrupting
`settings.json`.
510a624ae1Vlad Gaevsky committed on 9/4/2026, 3:28:40 PM· committed by GitHubparentba6b83f