mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-24 01:20:29 +01:00
d528c665e1
## Objective Extend the existing tabular preview to support `.jsonl` and `.ndjson` files, making it easier to compare fields across records. Discussed in https://github.com/zed-industries/zed/discussions/62917. ## Solution Parse each nonblank line as a JSON object and reuse the existing table preview. Top-level keys become columns in first-seen order, with new keys from later records appended to the right. - Preserve JSON values, including large numbers, without numeric conversion. - Display nested objects and arrays as compact JSON. - Keep missing fields, `null`, `"null"`, and empty strings distinct. - Show invalid-record errors with source line numbers and recover after edits. - Preserve sorting and filters unless column names or order change. - Add JSONL/NDJSON to the existing preview shortcuts and document the behavior. Also fix a crash found during CSV regression testing: deleting rows could leave the renderer using an old row mapping against shorter data. Clear the mapping and virtual list together before recomputing them. The preview remains read-only, accepts object records only, and uses the existing text-based sorting and full-file parsing behavior. ## Testing - All 20 tests in `tabular_data_preview` passed. - The multiline CSV deletion regression passed across 20 scheduler seeds. - `cargo fmt -p tabular_data_preview -- --check` passed. - `./script/clippy -p tabular_data_preview` passed. - `cargo build -p zed --bin zed` passed. - `git diff --check` passed. - Manual QA on macOS, including retesting the reported CSV crash. Windows and Linux were not tested locally. Large-file performance has not been benchmarked. To try it, open a `.jsonl` or `.ndjson` file and run `tabular data: open preview` or `tabular data: open preview to the side`. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase <img width="2358" height="1576" alt="image" src="https://github.com/user-attachments/assets/8f7e7725-5a5c-465d-aa0a-d61cbb22d04f" /> The example shows source-order columns, fields introduced by later records, nested values, and the distinction between missing values, nulls, and strings. Release Notes: - Added JSONL and NDJSON support to the tabular data preview. --------- Co-authored-by: Anthony Eid <anthony@zed.dev>