Skip to content

Commit 5563bd9

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

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 current selection
2444-
const [startPos, endPos] = cd.getSelection();
2443+
// get caret pos in text
2444+
const pos = cd.getSelection();
24452445

24462446
// replace selection contents
24472447
// with beautified text
24482448
cd.deleteCurrentSelection();
24492449
cd.insert(beautifiedText);
2450-
2451-
// reselect
2452-
cd.setSelection(startPos, endPos);
2450+
2451+
// restore pos in text
2452+
cd.setSelection(pos.start, pos.end);
24532453

24542454
// dispatch type event (simulate typing)
24552455
cd.dispatchTypeEvent();

0 commit comments

Comments
 (0)