Skip to content

Fixes #5272. Ctrl+Click on link in Markdown no longer shows context menu#5283

Merged
YourRobotOverlord merged 1 commit into
gui-cs:developfrom
YourRobotOverlord:fix/issue-5272-ctrl-click-markdown-popover
May 9, 2026
Merged

Fixes #5272. Ctrl+Click on link in Markdown no longer shows context menu#5283
YourRobotOverlord merged 1 commit into
gui-cs:developfrom
YourRobotOverlord:fix/issue-5272-ctrl-click-markdown-popover

Conversation

@YourRobotOverlord
Copy link
Copy Markdown
Collaborator

@YourRobotOverlord YourRobotOverlord commented May 9, 2026

Copilot Session

8584c489-d2b5-4dd6-bee4-a114a5d0665d

Summary

Fixes #5272.

When Ctrl+Click was used to follow a link in a Markdown view, the Select All/Copy context menu popover incorrectly appeared at the upper-left corner of the viewer (in addition to the link opening correctly).

Root Cause

View.Mouse.cs registers a default binding:

MouseBindings.Add(MouseFlags.LeftButtonReleased | MouseFlags.Ctrl, Command.Context);

Markdown.SetupBindingsAndCommands() already removes the LeftButtonReleased → Activate binding to prevent double-firing, but did not remove the LeftButtonReleased | Ctrl → Context binding. So during Ctrl+Click:

  1. LeftButtonReleased | CtrlCommand.ContextShowContextMenu() with no position → falls back to Point(0,0) → popover at upper-left ← bug
  2. LeftButtonClickedOnActivated → link opens correctly

Fix

One line added in SetupBindingsAndCommands():

MouseBindings.Remove(MouseFlags.LeftButtonReleased | MouseFlags.Ctrl);

Right-click (handled in OnMouseEvent) still shows the context menu as before.

Tests

Two regression tests added to MarkdownViewSelectionTests:

  • MouseBindings_CtrlLeftButtonReleased_IsNotBoundTo_Context — binding-level check
  • CtrlClick_On_Link_Opens_Link_And_Does_Not_Show_Context_Menu — end-to-end check

…text menu

Remove the base class Ctrl+LeftButtonReleased -> Command.Context mouse binding
from Markdown.SetupBindingsAndCommands(). The base View registers this binding
so Ctrl+Click can open a context menu, but the Markdown view already handles
right-click directly in OnMouseEvent and uses Ctrl+Click for link following.
Without this removal, Ctrl+Click would fire Command.Context -> ShowContextMenu()
via the LeftButtonReleased event, showing the Select All/Copy popover at the
upper-left corner (because no selection is active, GetContextMenuScreenPosition
falls back to Point(0,0)).

Add two regression tests:
- MouseBindings_CtrlLeftButtonReleased_IsNotBoundTo_Context: verifies the
  binding is absent on a fresh Markdown instance
- CtrlClick_On_Link_Opens_Link_And_Does_Not_Show_Context_Menu: end-to-end
  verification that Ctrl+Click fires LinkClicked without making the context
  menu visible

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YourRobotOverlord YourRobotOverlord requested a review from tig as a code owner May 9, 2026 04:03
Copy link
Copy Markdown
Member

@tig tig left a comment

Choose a reason for hiding this comment

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

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+Clicking a link in Markdown incorrectly displays Copy popover

2 participants