@@ -82,85 +82,98 @@ function processRangeTarget(
8282 activeSelection . start
8383 ) ;
8484
85- // Selection type column is actually a special form of ranged target
86- if (
87- anchorTarget . selectionType === "column" ||
88- activeTarget . selectionType === "column"
89- ) {
90- return processColumnTarget (
91- target ,
92- anchorTarget ,
93- activeTarget ,
94- isForward
95- ) ;
85+ switch ( target . rangeType ) {
86+ case "continuous" :
87+ return processContinuousRangeTarget (
88+ target ,
89+ anchorTarget ,
90+ activeTarget ,
91+ isForward
92+ ) ;
93+ case "vertical" :
94+ return processVerticalRangeTarget (
95+ target ,
96+ anchorTarget ,
97+ activeTarget ,
98+ isForward
99+ ) ;
96100 }
101+ }
102+ ) ;
103+ }
97104
98- const anchor = targetToRangeLimitPosition (
99- anchorTarget ,
100- isForward ,
101- ! target . excludeAnchor
102- ) ;
103- const active = targetToRangeLimitPosition (
104- activeTarget ,
105- ! isForward ,
106- ! target . excludeActive
107- ) ;
105+ function processContinuousRangeTarget (
106+ target : RangeTarget ,
107+ anchorTarget : TypedSelection ,
108+ activeTarget : TypedSelection ,
109+ isForward : boolean
110+ ) : TypedSelection [ ] {
111+ const anchor = targetToRangeLimitPosition (
112+ anchorTarget ,
113+ isForward ,
114+ ! target . excludeAnchor
115+ ) ;
116+ const active = targetToRangeLimitPosition (
117+ activeTarget ,
118+ ! isForward ,
119+ ! target . excludeActive
120+ ) ;
108121
109- const outerAnchor = target . excludeAnchor
110- ? null
111- : isForward
112- ? anchorTarget . selectionContext . outerSelection ?. start
113- : anchorTarget . selectionContext . outerSelection ?. end ;
114- const outerActive = target . excludeActive
115- ? null
116- : isForward
117- ? activeTarget . selectionContext . outerSelection ?. end
118- : activeTarget . selectionContext . outerSelection ?. start ;
119- const outerSelection =
120- outerAnchor != null || outerActive != null
121- ? new Selection ( outerAnchor ?? anchor , outerActive ?? active )
122- : null ;
122+ const outerAnchor = target . excludeAnchor
123+ ? null
124+ : isForward
125+ ? anchorTarget . selectionContext . outerSelection ?. start
126+ : anchorTarget . selectionContext . outerSelection ?. end ;
127+ const outerActive = target . excludeActive
128+ ? null
129+ : isForward
130+ ? activeTarget . selectionContext . outerSelection ?. end
131+ : activeTarget . selectionContext . outerSelection ?. start ;
132+ const outerSelection =
133+ outerAnchor != null || outerActive != null
134+ ? new Selection ( outerAnchor ?? anchor , outerActive ?? active )
135+ : null ;
123136
124- const startSelectionContext = target . excludeAnchor
125- ? null
126- : anchorTarget . selectionContext ;
127- const endSelectionContext = target . excludeActive
128- ? null
129- : activeTarget . selectionContext ;
130- const leadingDelimiterRange = isForward
131- ? startSelectionContext ?. leadingDelimiterRange
132- : endSelectionContext ?. leadingDelimiterRange ;
133- const trailingDelimiterRange = isForward
134- ? endSelectionContext ?. trailingDelimiterRange
135- : startSelectionContext ?. trailingDelimiterRange ;
137+ const startSelectionContext = target . excludeAnchor
138+ ? null
139+ : anchorTarget . selectionContext ;
140+ const endSelectionContext = target . excludeActive
141+ ? null
142+ : activeTarget . selectionContext ;
143+ const leadingDelimiterRange = isForward
144+ ? startSelectionContext ?. leadingDelimiterRange
145+ : endSelectionContext ?. leadingDelimiterRange ;
146+ const trailingDelimiterRange = isForward
147+ ? endSelectionContext ?. trailingDelimiterRange
148+ : startSelectionContext ?. trailingDelimiterRange ;
136149
137- return {
138- selection : {
139- selection : new Selection ( anchor , active ) ,
140- editor : anchorTarget . selection . editor ,
141- } ,
142- selectionType : anchorTarget . selectionType ,
143- selectionContext : {
144- containingListDelimiter :
145- anchorTarget . selectionContext . containingListDelimiter ,
146- isInDelimitedList : anchorTarget . selectionContext . isInDelimitedList ,
147- leadingDelimiterRange ,
148- trailingDelimiterRange ,
149- outerSelection ,
150- } ,
151- insideOutsideType : anchorTarget . insideOutsideType ,
152- position : "contents" ,
153- } ;
154- }
155- ) ;
150+ return [
151+ {
152+ selection : {
153+ selection : new Selection ( anchor , active ) ,
154+ editor : anchorTarget . selection . editor ,
155+ } ,
156+ selectionType : anchorTarget . selectionType ,
157+ selectionContext : {
158+ containingListDelimiter :
159+ anchorTarget . selectionContext . containingListDelimiter ,
160+ isInDelimitedList : anchorTarget . selectionContext . isInDelimitedList ,
161+ leadingDelimiterRange ,
162+ trailingDelimiterRange ,
163+ outerSelection ,
164+ } ,
165+ insideOutsideType : anchorTarget . insideOutsideType ,
166+ position : "contents" ,
167+ } ,
168+ ] ;
156169}
157170
158- function processColumnTarget (
171+ function processVerticalRangeTarget (
159172 target : RangeTarget ,
160173 anchorTarget : TypedSelection ,
161174 activeTarget : TypedSelection ,
162175 isForward : boolean
163- ) {
176+ ) : TypedSelection [ ] {
164177 const anchorLine = targetToLineLimitPosition (
165178 anchorTarget ,
166179 isForward ,
@@ -186,7 +199,7 @@ function processColumnTarget(
186199 ) ,
187200 editor : anchorTarget . selection . editor ,
188201 } ,
189- selectionType : "column" ,
202+ selectionType : anchorTarget . selectionType ,
190203 selectionContext : {
191204 containingListDelimiter :
192205 anchorTarget . selectionContext . containingListDelimiter ,
0 commit comments