Skip to content

Commit 49fd948

Browse files
author
Ives van Hoorne
committed
Fix prettify for files with syntax errors in CodeMirror
1 parent 3be9ca3 commit 49fd948

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/app/components/sandbox/CodeEditor/CodeMirror.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
286286
if (kind[1] === 'css') {
287287
await System.import('codemirror/mode/css/css');
288288
return 'css';
289-
} else if (kind[1] === 'html') {
289+
} else if (kind[1] === 'html' || kind[1] === 'vue') {
290290
await System.import('codemirror/mode/htmlmixed/htmlmixed');
291291
return 'htmlmixed';
292292
} else if (kind[1] === 'md') {
@@ -442,7 +442,6 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
442442
const newCode = await prettify.default(
443443
code,
444444
mode,
445-
preferences.lintEnabled,
446445
preferences.prettierConfig
447446
);
448447

src/app/components/sandbox/CodeEditor/Monaco.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,14 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
735735
prettify = async () => {
736736
const { id, title, preferences } = this.props;
737737
const code = this.getCode();
738-
const mode = this.getMode(title);
738+
const mode = await this.getMode(title);
739739

740740
if (mode === 'javascript' || mode === 'css') {
741741
try {
742742
const prettify = await import('app/utils/codemirror/prettify');
743743
const newCode = await prettify.default(
744744
code,
745745
mode === 'javascript' ? 'jsx' : mode,
746-
false, // Force false for eslint, since we would otherwise include 2 eslint bundles
747746
preferences.prettierConfig
748747
);
749748

src/app/utils/codemirror/prettify.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ function getParser(mode) {
1515
export default (function prettify(
1616
code,
1717
mode,
18-
eslintEnabled,
1918
prettierConfig = DEFAULT_PRETTIER_CONFIG
2019
) {
2120
return new Promise(resolve => {
@@ -36,6 +35,8 @@ export default (function prettify(
3635
}
3736
if (formatted) {
3837
resolve(formatted);
38+
} else {
39+
resolve(text);
3940
}
4041
};
4142
});

0 commit comments

Comments
 (0)