@@ -132,6 +132,7 @@ class TouchSelectionMenuController {
132132 #isScrolling = false ;
133133 #isPointerInteracting = false ;
134134 #shiftSelectionSession = null ;
135+ #pendingShiftSelectionClick = null ;
135136 #menuActive = false ;
136137 #menuRequested = false ;
137138 #enabled = true ;
@@ -176,13 +177,15 @@ class TouchSelectionMenuController {
176177 cancelAnimationFrame ( this . #stateSyncRaf) ;
177178 this . #stateSyncRaf = 0 ;
178179 this . #shiftSelectionSession = null ;
180+ this . #pendingShiftSelectionClick = null ;
179181 this . #hideMenu( true ) ;
180182 }
181183
182184 setEnabled ( enabled ) {
183185 this . #enabled = ! ! enabled ;
184186 if ( this . #enabled) return ;
185187 this . #shiftSelectionSession = null ;
188+ this . #pendingShiftSelectionClick = null ;
186189 this . #menuRequested = false ;
187190 this . #isPointerInteracting = false ;
188191 this . #isScrolling = false ;
@@ -254,6 +257,7 @@ class TouchSelectionMenuController {
254257 onSessionChanged ( ) {
255258 if ( ! this . #enabled) return ;
256259 this . #shiftSelectionSession = null ;
260+ this . #pendingShiftSelectionClick = null ;
257261 this . #menuRequested = false ;
258262 this . #isPointerInteracting = false ;
259263 this . #isScrolling = false ;
@@ -349,6 +353,11 @@ class TouchSelectionMenuController {
349353 selection : EditorSelection . range ( session . anchor , head ) ,
350354 userEvent : "select.extend" ,
351355 } ) ;
356+ this . #pendingShiftSelectionClick = {
357+ x : event . clientX ,
358+ y : event . clientY ,
359+ timeStamp : event . timeStamp ,
360+ } ;
352361 event . preventDefault ( ) ;
353362 }
354363
@@ -359,6 +368,24 @@ class TouchSelectionMenuController {
359368 return ! ! this . #isShiftSelectionActive( event ) ;
360369 }
361370
371+ consumePendingShiftSelectionClick ( event ) {
372+ const pending = this . #pendingShiftSelectionClick;
373+ this . #pendingShiftSelectionClick = null ;
374+ if ( ! pending || ! this . #enabled) return false ;
375+ if ( event . timeStamp - pending . timeStamp > TAP_MAX_DELAY ) return false ;
376+ if (
377+ Math . hypot ( event . clientX - pending . x , event . clientY - pending . y ) >
378+ TAP_MAX_DISTANCE
379+ ) {
380+ return false ;
381+ }
382+ const target = event . target ;
383+ if ( ! ( target instanceof Node ) || ! this . #view. dom . contains ( target ) )
384+ return false ;
385+ if ( this . #isIgnoredPointerTarget( target ) ) return false ;
386+ return true ;
387+ }
388+
362389 #shouldShowMenu( ) {
363390 if ( this . #isScrolling || this . #isPointerInteracting || ! this . #view. hasFocus )
364391 return false ;
0 commit comments