Skip to content

Commit 0bcf8b2

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

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

filebrowser.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2439,11 +2439,17 @@ function setupEditor() {
24392439
// compare current code with new code
24402440
// if the code is different, swap it
24412441
if (hashCode(selText) !== hashCode(beautifiedText)) {
2442-
2442+
2443+
// get current selection
2444+
const [startPos, endPos] = cd.getSelection();
2445+
24432446
// replace selection contents
24442447
// with beautified text
24452448
cd.deleteCurrentSelection();
24462449
cd.insert(beautifiedText);
2450+
2451+
// reselect
2452+
cd.setSelection(startPos, endPos);
24472453

24482454
// dispatch type event (simulate typing)
24492455
cd.dispatchTypeEvent();

0 commit comments

Comments
 (0)