# project_panel: Add markdown preview context menu item \(\#57112\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/db30c67ed254ee703399ea862cfc6acf33332b09)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: db30c67ed254ee703399ea862cfc6acf33332b09

Requested commit: db30c67ed254ee703399ea862cfc6acf33332b09

Commit: db30c67ed254ee703399ea862cfc6acf33332b09

Tree: 5d1fd2bdd8b1efe41a396f30c609467959340cdb

Author: Eli Stark

Committer: GitHub

## Message

```
project_panel: Add markdown preview context menu item (#57112)

Opening a markdown file from the project panel used to require four
steps:
- click the file (opens raw editor)
- right-click the editor tab
- select "Open Markdown Preview"
- then close the raw editor tab

This PR shortcuts that to a single right-click (or keypress) from the
project panel.

Right-clicking a markdown file in the project panel now shows an **Open
Markdown Preview** option. Selecting it opens the rendered markdown
preview directly — no raw editor tab is left behind. The same shortcut
used in the editor (Cmd+Shift+V on macOS, Ctrl+Shift+V on Windows/Linux)
also works when focus is in the project panel.

## How it works

- **Context menu**: `OpenMarkdownPreview` action is registered and
surfaced in the right-click menu only for `.md`/`.markdown` files.
- **Keybinding**: `cmd-shift-v` / `ctrl-shift-v` bound to
`project_panel::OpenMarkdownPreview` in the `ProjectPanel` context,
mirroring the existing editor binding.
- **Loading**: The file is opened via `open_path_preview` with
`focus_item: false, activate: false`, so the raw editor is loaded into
the buffer system but never becomes the visible tab.
- **Preview construction**: `MarkdownPreviewView::create_markdown_view`
is called directly (no `dispatch_action` indirection, which would have
been deferred and caused a race). The preview is added to the active
pane and the raw editor tab is removed atomically in one synchronous
pane update.
- **Pre-existing tabs**: Before loading, all panes are checked for an
existing item at the file's project path. If the file is already open in
raw mode, `remove_item` is skipped — the existing tab is left untouched.

Release Notes:

- Added "Open Markdown Preview" context menu item to Project Panel
markdown entries.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Co-authored-by: Tom Houlé <tom@tomhoule.com>
```

## Parents

- [eb877503230a2beba1105d1ecb9320d1f555347e](https://git.cafe/gitcafe/zed/commit/eb877503230a2beba1105d1ecb9320d1f555347e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/db30c67ed254ee703399ea862cfc6acf33332b09?format=markdown)
