File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -2440,16 +2440,16 @@ function setupEditor() {
24402440 // if the code is different, swap it
24412441 if ( hashCode ( selText ) !== hashCode ( beautifiedText ) ) {
24422442
2443- // get caret pos in text
2444- const pos = cd . getSelection ( ) ;
2445-
24462443 // replace selection contents
24472444 // with beautified text
24482445 cd . deleteCurrentSelection ( ) ;
24492446 cd . insert ( beautifiedText ) ;
2447+
2448+ // get caret pos in text
2449+ const pos = cd . getSelection ( ) ;
24502450
2451- // restore pos in text
2452- cd . setSelection ( pos . start , pos . end ) ;
2451+ // select beautified text
2452+ cd . setSelection ( pos . start , ( pos . start - beautifiedText . length ) ) ;
24532453
24542454 // dispatch type event (simulate typing)
24552455 cd . dispatchTypeEvent ( ) ;
You can’t perform that action at this time.
0 commit comments