Skip to content

Commit 52f78d6

Browse files
author
Ives van Hoorne
committed
Fix 'Save All Modified' for CodeMirror in combination with Prettify on Save
Fixes codesandbox#1020
1 parent 4d4a364 commit 52f78d6

File tree

1 file changed

+6
-3
lines changed
  • packages/app/src/app/components/CodeEditor/CodeMirror

1 file changed

+6
-3
lines changed

packages/app/src/app/components/CodeEditor/CodeMirror/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,13 @@ class CodemirrorEditor extends React.Component<Props, State> implements Editor {
303303
this.configureEmmet();
304304
};
305305

306-
changeCode = (code: string = '') => {
306+
changeCode = (code: string = '', moduleId: string) => {
307307
const pos = this.codemirror.getCursor();
308308
this.codemirror.setCursor(pos);
309-
if (this.getCode() !== code) {
309+
if (
310+
code !== this.getCode() &&
311+
(!moduleId || this.currentModule.id === moduleId)
312+
) {
310313
this.codemirror.setValue(code);
311314
}
312315
};
@@ -384,7 +387,7 @@ class CodemirrorEditor extends React.Component<Props, State> implements Editor {
384387

385388
handleChange = (cm: typeof CodeMirror, change: { origin: string }) => {
386389
if (change.origin !== 'setValue' && this.props.onChange) {
387-
this.props.onChange(cm.getValue());
390+
this.props.onChange(cm.getValue(), this.currentModule.shortid);
388391
}
389392
};
390393

0 commit comments

Comments
 (0)