如何将 Windows 的 EOL 设置为 LF,以便 API 通过 \n 获取值。不是 \r\n

SBi*_*han 6 monaco-editor

我使用 monaco.editor.create 方法来创建模型。问题是 monaco 正在将多行代码解析为 Windows 操作系统中的 \r\n 格式。

我尝试在 monaco.editor.create() 的 editorOptions 中使用 defaultEOL 作为“LF”

    let editorOptions = {
      value,
      quickSuggestions: { other: true, comments: true, strings: true },
      language: language,
      tabSize: tabSize,

      ...options
    };
    this._editor = monaco.editor.create(this._node, editorOptions);
Run Code Online (Sandbox Code Playgroud)

我希望摩纳哥编辑器请求我的 API 的值\n

Mat*_*kan 1

我使用以下内容:

let textModel = monaco.editor.createModel("");
textModel.setEOL(0);
Run Code Online (Sandbox Code Playgroud)

文档:

摩纳哥.editor.createModel

ITextModel.setEOL