Skip to content

Add auto_preview setting for Markdown, SVG, and CSV files#57010

Open
anuragxxd wants to merge 3 commits into
zed-industries:mainfrom
anuragxxd:feat/auto-preview-setting
Open

Add auto_preview setting for Markdown, SVG, and CSV files#57010
anuragxxd wants to merge 3 commits into
zed-industries:mainfrom
anuragxxd:feat/auto-preview-setting

Conversation

@anuragxxd
Copy link
Copy Markdown

Closes #10966

Summary

Adds an auto_preview setting under preview_tabs that automatically opens a preview when opening previewable files (Markdown, SVG, and CSV). The setting accepts three values:

  • "off" (default) — no automatic preview
  • "same_pane" — opens the preview in the same pane, replacing the editor tab
  • "to_side" — opens the preview in an adjacent pane to the side
{
  "preview_tabs": {
    "auto_preview": "same_pane"
  }
}

Demo

zed-auto-preview-demo.mov

Approach

Each preview crate (markdown_preview, svg_preview, csv_preview) subscribes to workspace::Event::ItemAdded. When a new editor is added:

  1. Check the auto_preview setting
  2. Verify the file is previewable (by extension for Markdown/SVG/CSV)
  3. Use window.defer to create the preview view after the editor item is fully mounted

Using window.defer and calling preview creation functions directly (bypassing the action system) avoids both the dispatch timing issue from #48733 and reentrancy panics from nested pane.add_item calls. For to_side mode, the code falls back to any existing non-active pane before attempting split_pane, since find_pane_in_direction depends on bounding boxes that may not exist yet in the deferred context.

Changes

  • Setting: 3-variant AutoPreviewMode enum (Off, SamePane, ToSide) in PreviewTabsSettingsContent
  • Markdown: auto-preview via file extension (.md, .markdown)
  • SVG: auto-preview via file extension (.svg)
  • CSV: auto-preview via file extension (.csv), gated behind TabularDataPreviewFeatureFlag
  • Settings UI: dropdown in the Preview Tabs section (registered in SettingFieldRenderer)
  • VSCode import: maps markdown.extension.preview.autoShowPreviewToSideauto_preview: "to_side"
  • Documentation: all-settings.md and default.json updated
  • Tests: 3 integration tests (same_pane creates preview, off doesn't, non-markdown is ignored)

Context

This is a resubmission of #56950 with fixes for the settings UI renderer registration ("NO RENDERER" issue) and a to_side pane resolution bug. Built and tested end-to-end on macOS 15 with Xcode 26.

Prior art: #44346, #48733. Addresses all review feedback from @SomeoneToIgnore's #48733 review cycle.

Release Notes:

  • Added auto_preview setting to automatically open a preview when opening Markdown, SVG, or CSV files

Add a new `auto_preview` setting under `preview_tabs` that automatically
opens a preview when opening previewable files. The setting accepts three
values: `off` (default), `same_pane`, and `to_side`.

Each preview crate (markdown_preview, svg_preview, csv_preview) subscribes
to workspace::Event::ItemAdded and uses window.defer to create the preview
view after the editor item is fully mounted, avoiding reentrancy issues
that caused the previous attempt (PR zed-industries#48733) to fail.

Includes settings UI dropdown, VSCode import for
markdown.extension.preview.autoShowPreviewToSide, documentation in
all-settings.md, and integration tests.

Closes zed-industries#10966
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 17, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label May 17, 2026
@lafllamme

This comment has been minimized.

@anuragxxd
Copy link
Copy Markdown
Author

@SomeoneToIgnore CI is green now. I also built this locally on macOS and tested both same_pane and to_side end to end. The demo in the PR description shows the fixed settings UI and preview behavior. Would appreciate another look when you have time.

Copy link
Copy Markdown
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.
Now, we need to consider the usability: for that, you have to run the app and use it a bit with various cases.

Here's what I see as totally not acceptable:

slop.mov

Please, open the editor or IDE of your choice and compare with this behavior.
For example, VSCode:

has_some_thought_in_it.mov

I see at least the following UX discrepancies:

  • Auto preview actually opens when I open another file
  • Auto preview does not get the focus, it's the editor that keeps it
  • Auto preview gets replaced instead of duplicating

Let's fix this and apply more rigorous manual testing first, then continue.

Comment thread crates/settings_ui/src/page_data.rs Outdated
Comment thread docs/src/reference/all-settings.md Outdated
Comment thread assets/settings/default.json Outdated
Comment thread assets/settings/default.json Outdated
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Comment thread crates/settings_ui/src/page_data.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure markdown files to open in preview mode by default

3 participants