mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-02 05: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>
36 lines
745 B
TOML
36 lines
745 B
TOML
[package]
|
|
name = "tabular_data_preview"
|
|
version = "0.1.0"
|
|
publish.workspace = true
|
|
edition.workspace = true
|
|
|
|
[lib]
|
|
path = "src/tabular_data_preview.rs"
|
|
doctest = false
|
|
|
|
[dependencies]
|
|
anyhow.workspace = true
|
|
fuzzy.workspace = true
|
|
gpui.workspace = true
|
|
editor.workspace = true
|
|
picker.workspace = true
|
|
ui.workspace = true
|
|
workspace.workspace = true
|
|
log.workspace = true
|
|
indexmap.workspace = true
|
|
serde_json.workspace = true
|
|
text.workspace = true
|
|
|
|
[dev-dependencies]
|
|
gpui = { workspace = true, features = ["test-support"] }
|
|
project = { workspace = true, features = ["test-support"] }
|
|
proptest.workspace = true
|
|
util.workspace = true
|
|
workspace = { workspace = true, features = ["test-support"] }
|
|
|
|
[features]
|
|
dev-tools = []
|
|
|
|
[lints]
|
|
workspace = true
|