Files
zed/crates
Cameron BedardandSmit Barmase f9a4bfd826 markdown_preview: Restore preview panes on workspace reload (#56972)
Markdown preview tabs were lost on restart because `MarkdownPreviewView`
implements `Item` and `SearchableItem` but never opted into
`SerializableItem`, so the workspace serializer silently skipped it.

This change adds persistence, modeled on the existing `ImageView` and
`Editor` patterns:

- Add a `persistence` submodule storing `(workspace_id, item_id,
abs_path, mode)` in a `markdown_previews` table.
- `serialize` records the active editor's file path and the preview
mode. `deserialize` reopens the file as a buffer and constructs a new
`MarkdownPreviewView` around it.
- Register the item type in `markdown_preview::init`.

Untitled markdown buffers and previews whose source file no longer
exists are not restored — `serialize` and `deserialize` return `None`
and `Err` respectively, mirroring `ImageView`.

`csv_preview` and `svg_preview` have the same `SerializableItem` defect;
left out of this PR to keep scope focused.

Closes #38581
Part of #7371

Release Notes:

- Fixed Markdown preview tabs not being restored when reopening a
workspace

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 is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

on the no tests bit, consistent with ImageView, ComponentPreview,
GitGraph, TerminalView, and every other SerializableItem impl other than
Editor.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-06-16 15:46:37 +00:00
..
2026-05-04 06:30:47 +00:00
2026-04-29 10:27:47 +00:00
2026-05-04 06:30:47 +00:00
2026-04-29 10:27:47 +00:00
…
2026-06-06 20:28:26 +00:00
2026-05-27 10:31:53 +00:00
2026-04-29 10:27:47 +00:00
2026-05-27 10:31:53 +00:00
2026-06-09 22:46:22 +00:00
2026-05-27 10:31:53 +00:00
2026-06-16 15:07:25 +00:00