@@ -172,6 +172,39 @@ async function EditorManager($header, $body) {
172172 } ,
173173 ) ;
174174
175+ const shiftTapSelectionFix = EditorView . domEventHandlers ( {
176+ mousedown ( event , view ) {
177+ // Check if Shift is held during the tap/click
178+ if ( event . shiftKey ) {
179+ // Get the current document position of the tap
180+ const pos = view . posAtCoords ( { x : event . clientX , y : event . clientY } ) ;
181+
182+ if ( pos !== null ) {
183+ const { state } = view ;
184+ const currentSelection = state . selection . main ;
185+
186+ // Create a new selection: keep the existing anchor, move the head to the tap position
187+ const newSelection = EditorSelection . range (
188+ currentSelection . anchor ,
189+ pos ,
190+ ) ;
191+
192+ // Dispatch the transaction to update the UI
193+ view . dispatch ( {
194+ selection : newSelection ,
195+ scrollIntoView : true ,
196+ userEvent : "select.extend" ,
197+ } ) ;
198+
199+ // Prevent the default behavior which might reset the anchor
200+ event . preventDefault ( ) ;
201+ return true ;
202+ }
203+ }
204+ return false ;
205+ } ,
206+ } ) ;
207+
175208 const touchSelectionUpdateExtension = EditorView . updateListener . of (
176209 ( update ) => {
177210 if ( ! touchSelectionController ) return ;
@@ -725,6 +758,7 @@ async function EditorManager($header, $body) {
725758 fixedHeightTheme ,
726759 scrollPastEnd ( ) ,
727760 pointerCursorVisibilityExtension ,
761+ shiftTapSelectionFix ,
728762 touchSelectionUpdateExtension ,
729763 search ( ) ,
730764 // Ensure read-only can be toggled later via compartment
@@ -1088,6 +1122,7 @@ async function EditorManager($header, $body) {
10881122 fixedHeightTheme ,
10891123 scrollPastEnd ( ) ,
10901124 pointerCursorVisibilityExtension ,
1125+ shiftTapSelectionFix ,
10911126 touchSelectionUpdateExtension ,
10921127 search ( ) ,
10931128 // Keep dynamic compartments across state swaps
0 commit comments