未验证 提交 32dfa337 编写于 作者: M Marcin Maciaszczyk 提交者: GitHub

Do not crash chip dialog if the prettify function fails (#5108)

上级 1f66b1c1
......@@ -143,15 +143,19 @@ export class TextInputComponent implements OnInit, AfterViewInit, OnChanges {
return;
}
switch (this.mode) {
case 'json':
this.text = JSON.stringify(JSON.parse(this.text), null, '\t');
// Replace \n with new lines
this.text = this.text.replace(new RegExp(/\\n/g), '\n\t\t');
break;
default:
// Do nothing when mode is not recognized.
break;
try {
switch (this.mode) {
case 'json':
this.text = JSON.stringify(JSON.parse(this.text), null, '\t');
// Replace \n with new lines
this.text = this.text.replace(new RegExp(/\\n/g), '\n\t\t');
break;
default:
// Do nothing when mode is not recognized.
break;
}
} catch (e) {
// Ignore any errors in case of wrong format. Formatting will not be applied.
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册