瀏覽代碼

修复脚本中包含文本块格式化代码时结果不正确的问题

mxd 3 年之前
父節點
當前提交
91ac8301ab
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      magic-editor/src/console/src/scripts/beautifier/core/output.js

+ 3 - 1
magic-editor/src/console/src/scripts/beautifier/core/output.js

@@ -310,7 +310,9 @@ Output.prototype.get_code = function(eol) {
 
   var sweet_code = this.__lines.join('\n');
 
-  if (eol !== '\n') {
+  if (eol === '\r\n') {
+    sweet_code = sweet_code.replaceAll(/([^\r])\n/g, `$1${eol}`);
+  }else if (eol !== '\n') {
     sweet_code = sweet_code.replace(/[\n]/g, eol);
   }
   return sweet_code;