Newline handling is currently tied to the build platform. The formatter converts \n to \r\n only on Windows builds, via replaceNewlines behind ENABLE_WINDOWS_NEWLINES, and only in the CLI file writing path. Two problems follow:
-
It ignores the input file's actual newline style. A CRLF file formatted on Linux comes out LF, and an LF file formatted on Windows comes out CRLF. The tool changes a property of the file the user did not ask to change.
-
formatNode itself returns LF, so any consumer that does not replicate the CLI's platform logic gets LF regardless. The language server (now in webdevred/jbeam-edit-lsp) consumes formatNode directly and therefore always emits LF, silently converting CRLF documents.
Better: detect the input's newline style and preserve it, independent of platform. A CRLF file stays CRLF, an LF file stays LF. Expose this so the CLI and the language server share one mechanism rather than each reimplementing it.
Related consumer: runFormatNode in webdevred/jbeam-edit-lsp (src/JbeamEdit/LSP/Handlers/Formatting.hs).
Newline handling is currently tied to the build platform. The formatter converts
\nto\r\nonly on Windows builds, viareplaceNewlinesbehindENABLE_WINDOWS_NEWLINES, and only in the CLI file writing path. Two problems follow:It ignores the input file's actual newline style. A CRLF file formatted on Linux comes out LF, and an LF file formatted on Windows comes out CRLF. The tool changes a property of the file the user did not ask to change.
formatNodeitself returns LF, so any consumer that does not replicate the CLI's platform logic gets LF regardless. The language server (now in webdevred/jbeam-edit-lsp) consumesformatNodedirectly and therefore always emits LF, silently converting CRLF documents.Better: detect the input's newline style and preserve it, independent of platform. A CRLF file stays CRLF, an LF file stays LF. Expose this so the CLI and the language server share one mechanism rather than each reimplementing it.
Related consumer:
runFormatNodein webdevred/jbeam-edit-lsp (src/JbeamEdit/LSP/Handlers/Formatting.hs).