@@ -10,13 +10,12 @@ abstract class SetSelectionBase implements SimpleAction {
1010 private rangeMode : "content" | "before" | "after" ,
1111 ) {
1212 this . run = this . run . bind ( this ) ;
13- this . getSelection = this . getSelection . bind ( this ) ;
1413 }
1514
1615 async run ( targets : Target [ ] ) : Promise < ActionReturnValue > {
1716 const editor = ensureSingleEditor ( targets ) ;
1817
19- const targetSelections = targets . map ( this . getSelection ) ;
18+ const targetSelections = this . getSelections ( targets ) ;
2019
2120 const selections =
2221 this . selectionMode === "add"
@@ -32,17 +31,20 @@ abstract class SetSelectionBase implements SimpleAction {
3231 } ;
3332 }
3433
35- private getSelection ( target : Target ) : Selection {
34+ private getSelections ( targets : Target [ ] ) : Selection [ ] {
3635 switch ( this . rangeMode ) {
3736 case "content" :
38- return target . contentSelection ;
37+ return targets . map ( ( target ) => target . contentSelection ) ;
3938 case "before" :
40- return new Selection (
41- target . contentRange . start ,
42- target . contentRange . start ,
39+ return targets . map (
40+ ( target ) =>
41+ new Selection ( target . contentRange . start , target . contentRange . start ) ,
4342 ) ;
4443 case "after" :
45- return new Selection ( target . contentRange . end , target . contentRange . end ) ;
44+ return targets . map (
45+ ( target ) =>
46+ new Selection ( target . contentRange . end , target . contentRange . end ) ,
47+ ) ;
4648 }
4749 }
4850}
0 commit comments