Merge pull request #32114 from overleaf/mg-context-menu-cursor-movemenet

Move cursor on right-click within same line

GitOrigin-RevId: 8b622e9f557ecb1a33b7ba1a80d5752e05a72718
This commit is contained in:
Malik Glossop
2026-03-19 09:05:37 +00:00
committed by Copybot
parent f947b549e4
commit 7bb4427f93
2 changed files with 59 additions and 6 deletions
@@ -153,13 +153,11 @@ function isPositionInsideSelection(pos: number, from: number, to: number) {
function isPositionInsideAnyRangeOrCursor(view: EditorView, pos: number) {
for (const range of view.state.selection.ranges) {
// If it's a cursor, treat a right-click anywhere on the same line as "inside".
// This avoids collapsing multi-cursor selections when right-clicking on blank lines
// or to the right of the caret.
// If it's a cursor (not a selection), only treat it as "inside" when
// right-clicking exactly on the cursor position. This allows cursor
// movement when clicking elsewhere on the same line.
if (range.from === range.to) {
const clickedLine = view.state.doc.lineAt(pos)
const cursorLine = view.state.doc.lineAt(range.from)
if (clickedLine.number === cursorLine.number) {
if (pos === range.from) {
return true
}
continue