Files
zed/crates/editor
Josh Kent 80ee0a3563 markdown_preview: Add Show Source to preview tab menu (#65081)
## Summary

Markdown files can now open in preview by default, but there's no
discoverable way back to the raw source.
`markdown::CloseAndReturnToEditor` exists (`cmd-shift-v` /
`ctrl-shift-v`), but nothing in the UI points to it.

This adds a "Show Source" entry to the preview tab's context menu that
triggers that action.

Tab menu entries that dispatch actions only work on the active tab.
Inactive tabs aren't rendered, so they aren't in the dispatch tree and
never receive the action. Because of that:

- "Show Source" only appears when the preview is the active tab.
- The editor's "Open Markdown Preview" and "Open SVG Preview" entries
had the same problem, so they're now hidden on inactive tabs too.

## Testing

- `cargo test -p markdown_preview`
- `./script/clippy -p markdown_preview -p editor`
- Manually verified on macOS:
- Right-click the active Markdown preview tab → "Show Source" closes the
preview and focuses the source editor.
- Right-click an inactive preview tab or inactive Markdown editor tab →
no preview entries are shown.

To try it: open any `.md` file in preview, right-click the preview tab,
choose "Show Source".

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Added a "Show Source" option to the Markdown preview tab context menu.
- Fixed "Open Markdown Preview" and "Open SVG Preview" appearing in the
tab context menu of inactive tabs, where they had no effect.
2026-10-03 02:35:10 +00:00
..