Skip to content

Collapse dl's duplicate indent=2 JSON formatter onto core's #346

Description

@blooop

Question

A third copy of the ensure_ascii + surrogate-pair escaping survives #315 in the dl renderer's pretty formatter for --ls --json. That build collapsed the other two (core's json.rs and the metadata store's) into one shared write_ensure_ascii, but left this one deliberately: sharing it needs a new pub item on devlaunch-core, which moves a public-API snapshot — off-limits until Split the API snapshots lands so the snapshot files move once.

Scope it as the whole formatter, not just the escaper. The review of PR #345 measured the actual residue: render.rs:196-295 and metadata.rs:1015+ are two near-identical ~100-line indent=2 formatters that each delegate to serde_json::ser::PrettyFormatter, so the escaping is only the smaller half of what is duplicated. Exporting one pub formatter (or one pub document-writing fn) costs the same single pub line the escaper alone would have cost, and retires the duplicated layout delegation as well. PythonPretty has exactly one production caller — python_json_document at render.rs:180, reached only from commands.rs:225 — so the surface being replaced is small and fully known.

Red-first at the shared seam, and add the pin the other two got. Same principle as #315: a legitimate difference stays (this document is indented, the compact one is on one line); what must not stay is two copies of one fact.

Note the ordering trap: doing this before #338 merges would move a public-API snapshot twice, which is exactly what that ticket exists to prevent.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions