Add auto_preview setting for Markdown, SVG, and CSV files#57010
Open
anuragxxd wants to merge 3 commits into
Open
Add auto_preview setting for Markdown, SVG, and CSV files#57010anuragxxd wants to merge 3 commits into
anuragxxd wants to merge 3 commits into
Conversation
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
This comment has been minimized.
This comment has been minimized.
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. |
SomeoneToIgnore
requested changes
May 24, 2026
Contributor
There was a problem hiding this comment.
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.
Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10966
Summary
Adds an
auto_previewsetting underpreview_tabsthat 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 toworkspace::Event::ItemAdded. When a new editor is added:auto_previewsettingwindow.deferto create the preview view after the editor item is fully mountedUsing
window.deferand calling preview creation functions directly (bypassing the action system) avoids both the dispatch timing issue from #48733 and reentrancy panics from nestedpane.add_itemcalls. Forto_sidemode, the code falls back to any existing non-active pane before attemptingsplit_pane, sincefind_pane_in_directiondepends on bounding boxes that may not exist yet in the deferred context.Changes
AutoPreviewModeenum (Off,SamePane,ToSide) inPreviewTabsSettingsContent.md,.markdown).svg).csv), gated behindTabularDataPreviewFeatureFlagSettingFieldRenderer)markdown.extension.preview.autoShowPreviewToSide→auto_preview: "to_side"all-settings.mdanddefault.jsonupdatedContext
This is a resubmission of #56950 with fixes for the settings UI renderer registration ("NO RENDERER" issue) and a
to_sidepane 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:
auto_previewsetting to automatically open a preview when opening Markdown, SVG, or CSV files