Skip to content

Commit f44dd7f

Browse files
Treat small selections as clicks in editor
Change click handler to bail for any non-trivial selection (>3 chars) instead of only multi-line selections. Small selections (<4 chars) from slight mouse movement are now treated as clicks and corrected. Comments updated to clarify behavior and note that list normalization also collapses accidental small selections in the marker area.
1 parent 15a50f6 commit f44dd7f

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

app/src/features/editor/note-editor.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,14 @@ export const NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(
481481
return false;
482482
},
483483
click(event, view) {
484-
// Bail for multi-line selections (real drags). Same-line
485-
// selections from slight mouse movement are corrected below.
484+
// Bail for any non-trivial selection (real drags).
485+
// Small selections from slight mouse movement (< 4 chars)
486+
// are treated as clicks and corrected. The list normalization
487+
// filter also collapses accidental small selections in the
488+
// marker area.
486489
const sel = view.state.selection.main;
487-
if (!sel.empty) {
488-
const fromLine = view.state.doc.lineAt(sel.from);
489-
const toLine = view.state.doc.lineAt(sel.to);
490-
if (fromLine.number !== toLine.number) {
491-
return false;
492-
}
490+
if (!sel.empty && sel.to - sel.from > 3) {
491+
return false;
493492
}
494493

495494
const lineStart = getLeadingPaddingClickLineStart(view, event);

0 commit comments

Comments
 (0)