Skip to content

Commit c20a985

Browse files
committed
Update filebrowser.js
1 parent 5563bd9 commit c20a985

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

filebrowser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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();

0 commit comments

Comments
 (0)