Skip to content

Disable double-click to reveal source for .copilotmd files in markdown preview#267517

Merged
benibenj merged 3 commits intomainfrom
copilot/fix-cbe4ab2e-7a10-4c5c-8b6c-3a40bc969ea9
Oct 3, 2025
Merged

Disable double-click to reveal source for .copilotmd files in markdown preview#267517
benibenj merged 3 commits intomainfrom
copilot/fix-cbe4ab2e-7a10-4c5c-8b6c-3a40bc969ea9

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 19, 2025

This PR disables the double-click behavior that reveals markdown source for files with the .copilotmd extension, while preserving all existing functionality for regular .md files.

Problem

Currently, double-clicking in the markdown preview reveals the source markdown for all markdown files. For .copilotmd files, this behavior should be disabled to prevent users from accidentally switching to the source view.

Solution

Added a file extension check in the double-click event listener in extensions/markdown-language-features/preview-src/index.ts. The implementation:

  1. Checks if the current document resource ends with .copilotmd
  2. Returns early if it's a copilotmd file, preventing the double-click action
  3. Preserves all existing behavior for regular markdown files
document.addEventListener('dblclick', event => {
    if (!settings.settings.doubleClickToSwitchToEditor) {
        return;
    }

    // Disable double-click to switch editor for .copilotmd files
    if (documentResource && documentResource.endsWith('.copilotmd')) {
        return;
    }

    // ... rest of existing logic unchanged
});

Impact

  • .copilotmd files: Double-click no longer reveals markdown source
  • .md files: Double-click behavior unchanged (still reveals source)
  • ✅ All other markdown preview features remain fully functional (links, scrolling, rendering)

This is a minimal, surgical change that addresses the specific requirement without affecting existing functionality.

This pull request was created as a result of the following prompt from Copilot chat.

The current behavior in CopilotMD files allows users to double-click and reveal the Markdown source. We want to disable this specific double-click behavior in files with the .copilotmd extension, so double-clicking does not reveal the Markdown source. All other Markdown editing behaviors should remain unaffected for non-copilotmd files.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: joaomoreno <22350+joaomoreno@users.noreply.github.com>
Copilot AI changed the title [WIP] Disable 'Reveal Markdown Source' on Double Click in CopilotMD Files Disable double-click to reveal source for .copilotmd files in markdown preview Sep 19, 2025
Copilot AI requested a review from joaomoreno September 19, 2025 18:34
@joaomoreno joaomoreno marked this pull request as ready for review September 22, 2025 13:33
Copilot AI review requested due to automatic review settings September 22, 2025 13:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR disables the double-click to reveal source functionality specifically for .copilotmd files in the markdown preview, while preserving the existing behavior for regular .md files.

  • Adds a file extension check to prevent double-click source reveal for .copilotmd files
  • Maintains all existing double-click behavior for standard markdown files
  • Uses early return pattern to exit the event handler when dealing with copilotmd files

@vs-code-engineering vs-code-engineering Bot added this to the September 2025 milestone Sep 22, 2025
Copy link
Copy Markdown
Member

@joaomoreno joaomoreno left a comment

Choose a reason for hiding this comment

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

Ugly fix but OK...

@joaomoreno joaomoreno requested a review from mjbvz September 22, 2025 13:36
@TylerLeonhardt
Copy link
Copy Markdown
Member

Does this work in Copilot Instuctions files which have the Language Type of "Instructions" and not "Markdown"?

@joaomoreno joaomoreno enabled auto-merge (squash) September 30, 2025 08:23
@joaomoreno
Copy link
Copy Markdown
Member

It only works if the file has file extension .copilotmd.

chrmarti
chrmarti previously approved these changes Sep 30, 2025
Comment thread extensions/markdown-language-features/preview-src/index.ts Outdated
@benibenj benibenj disabled auto-merge October 3, 2025 08:22
@benibenj benibenj enabled auto-merge (squash) October 3, 2025 08:24
@benibenj benibenj merged commit 3a1b1ed into main Oct 3, 2025
28 checks passed
@benibenj benibenj deleted the copilot/fix-cbe4ab2e-7a10-4c5c-8b6c-3a40bc969ea9 branch October 3, 2025 08:28
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants