Skip to content

Fix context menu caret behavior when right-clicking inside a selection#1071

Merged
dail8859 merged 1 commit into
dail8859:masterfrom
saberoueslati:worktree-fix+issue-780-context-menu-selection
Jun 8, 2026
Merged

Fix context menu caret behavior when right-clicking inside a selection#1071
dail8859 merged 1 commit into
dail8859:masterfrom
saberoueslati:worktree-fix+issue-780-context-menu-selection

Conversation

@saberoueslati

Copy link
Copy Markdown
Contributor

Fixes #780

The editor context menu had inconsistent behavior; this meant right-clicking outside a selection with the intent to act on that location would still operate on wherever the caret happened to be.

Change

MainWindow.cpp — In the customContextMenuRequested handler inside addEditor, a call to selectionFromPoint now checks whether the right-click landed inside an existing selection. If it did, the selection and caret are left untouched. If it did not, setEmptySelection is called to move the caret to the clicked position, matching standard editor behavior.

Behavior

  • Right-clicking inside a selection preserves the selection; context menu actions operate on the selected text
  • Right-clicking outside a selection clears it and moves the caret to the clicked position
  • URL detection (Copy URL) is unaffected — contextMenuPos is still set before the check
  • No new settings, files, or API changes

Manual test after the fix :

Screencast.from.2026-06-07.23-28-54.webm

@dail8859 dail8859 merged commit 4582e62 into dail8859:master Jun 8, 2026
12 checks passed
@dail8859

dail8859 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks! I was not aware Scintilla had the selectionFromPoint() API but that's exactly what is needed.

@saberoueslati

Copy link
Copy Markdown
Contributor Author

Glad to help @dail8859, while you are at it, can you please review this PR #1045 ?

Thank you

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.

Editor Context Menu Location

2 participants