Skip to content

Fix double-click text selection and tab bar flicker in Markdown preview#60817

Open
feeiyu wants to merge 1 commit into
zed-industries:mainfrom
feeiyu:fix_markdown_preview_flickering
Open

Fix double-click text selection and tab bar flicker in Markdown preview#60817
feeiyu wants to merge 1 commit into
zed-industries:mainfrom
feeiyu:fix_markdown_preview_flickering

Conversation

@feeiyu

@feeiyu feeiyu commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Objective

Fixes #60812

Previously, double-clicking in the preview updated the source editor selection/cursor position, moved focus to the source editor, and stopped the event from propagating. This prevented normal text selection in the preview. When the source editor was in the same pane but not the active tab, focus was then restored back to the preview, causing the tab/tab bar to flicker.

Solution

Update the source editor selection/cursor position on single-click instead of double-click, while keeping focus in the Markdown preview. This leaves double-click behavior available for normal text selection in the preview.

  • This approach keeps Markdown preview interactions consistent with common text behavior: double-clicking text should select the word/text under the cursor..
  • The source editor selection/cursor position is still updated on single-click so the preview can continue to keep the source editor in sync with the location the user is inspecting.

Testing

Manually tested the Markdown preview click behavior.

I also tried adding a regression test using simulate_event to simulate mouse events, but I could not find a reliable API for locating the rendered text position inside the Markdown preview. Because of that, this was validated manually.

Manual test steps:

  1. Open a Markdown file.
  2. Open the Markdown preview for that file.
  3. Keep the source editor and Markdown preview as separate tabs in the same pane.
  4. Activate the Markdown preview tab.
  5. Single-click text in the Markdown preview.
    • Confirm the source editor selection/cursor position is updated.
    • Confirm focus remains in the Markdown preview.
    • Confirm the tab bar does not flicker.
  6. Double-click text in the Markdown preview.
    • Confirm the text in the preview is selected.
    • Confirm focus remains in the Markdown preview.
    • Confirm the tab bar does not flicker.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Showcase

after change:

2026-07-11.23-44-16.webm

Release Notes:

  • Fixed double-click text selection and tab bar flicker in Markdown preview.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 11, 2026
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Jul 11, 2026
@feeiyu feeiyu changed the title Fixed double-click text selection and tab bar flicker in Markdown preview. Fixed double-click text selection and tab bar flicker in Markdown preview Jul 11, 2026
@maxdeviant maxdeviant changed the title Fixed double-click text selection and tab bar flicker in Markdown preview Fix double-click text selection and tab bar flicker in Markdown preview Jul 11, 2026
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 guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown preview double-click does not select text and causes tab bar flicker

1 participant