Skip to content

Commit beb3cd4

Browse files
committed
Make ot repairs more graceful
This makes sure that the cursor doesn't jump when the code gets repaired
1 parent 247d46d commit beb3cd4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/app/src/app/overmind/effects/vscode/ModelsHandler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Sandbox,
66
UserSelection,
77
} from '@codesandbox/common/lib/types';
8+
import { getTextOperation } from '@codesandbox/common/lib/utils/diff';
89
import { indexToLineAndColumn } from 'app/overmind/utils/common';
910
import { actions, dispatch } from 'codesandbox-api';
1011
import { css } from 'glamor';
@@ -195,8 +196,10 @@ export class ModelsHandler {
195196
return;
196197
}
197198

199+
const oldCode = model.getValue();
200+
const changeOperation = getTextOperation(oldCode, module.code);
198201
this.isApplyingOperation = true;
199-
await model.setValue(module.code);
202+
this.applyOperationToModel(changeOperation, false, model);
200203
this.isApplyingOperation = false;
201204
}
202205

0 commit comments

Comments
 (0)