@@ -6,7 +6,7 @@ import {ViewUpdate, PluginValue, clickAddsSelectionRange, dragMovesSelection as
66 logException , mouseSelectionStyle , PluginInstance , focusChangeEffect , getScrollMargins ,
77 clipboardInputFilter , clipboardOutputFilter } from "./extension"
88import browser from "./browser"
9- import { groupAt , skipAtomicRanges } from "./cursor"
9+ import { groupAt , skipAtomsForSelection } from "./cursor"
1010import { getSelection , focusPreventScroll , Rect , dispatchKey , scrollableParents } from "./dom"
1111import { applyDOMChangeInner } from "./domchange"
1212
@@ -376,29 +376,8 @@ class MouseSelection {
376376 if ( this . dragging === false ) this . select ( this . lastEvent )
377377 }
378378
379- skipAtoms ( sel : EditorSelection ) {
380- let ranges = null
381- for ( let i = 0 ; i < sel . ranges . length ; i ++ ) {
382- let range = sel . ranges [ i ] , updated = null
383- if ( range . empty ) {
384- let pos = skipAtomicRanges ( this . atoms , range . from , 0 )
385- if ( pos != range . from ) updated = EditorSelection . cursor ( pos , - 1 )
386- } else {
387- let from = skipAtomicRanges ( this . atoms , range . from , - 1 )
388- let to = skipAtomicRanges ( this . atoms , range . to , 1 )
389- if ( from != range . from || to != range . to )
390- updated = EditorSelection . range ( range . from == range . anchor ? from : to , range . from == range . head ? from : to )
391- }
392- if ( updated ) {
393- if ( ! ranges ) ranges = sel . ranges . slice ( )
394- ranges [ i ] = updated
395- }
396- }
397- return ranges ? EditorSelection . create ( ranges , sel . mainIndex ) : sel
398- }
399-
400379 select ( event : MouseEvent ) {
401- let { view} = this , selection = this . skipAtoms ( this . style . get ( event , this . extend , this . multiple ) )
380+ let { view} = this , selection = skipAtomsForSelection ( this . atoms , this . style . get ( event , this . extend , this . multiple ) )
402381 if ( this . mustSelect || ! selection . eq ( view . state . selection , this . dragging === false ) )
403382 this . view . dispatch ( {
404383 selection,
@@ -549,6 +528,8 @@ handlers.mousedown = (view, event: MouseEvent) => {
549528 mouseSel . start ( event )
550529 return mouseSel . dragging === false
551530 }
531+ } else {
532+ view . inputState . setSelectionOrigin ( "select.pointer" )
552533 }
553534 return false
554535}
0 commit comments