From 820eec990d5f332d30cf939954c8672a43a0459e Mon Sep 17 00:00:00 2001 From: Li BingMuyou <77159535+li6in9muyou@users.noreply.github.com> Date: Sun, 14 Apr 2024 06:01:39 +0800 Subject: fix: handle windows line ending when config.stdin is true (#361) --- lua/conform/runner.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lua') diff --git a/lua/conform/runner.lua b/lua/conform/runner.lua index ff58570..0f31e64 100644 --- a/lua/conform/runner.lua +++ b/lua/conform/runner.lua @@ -345,6 +345,11 @@ local function run_formatter(bufnr, formatter, config, ctx, input_lines, opts, c output = vim.split(content, "\r?\n", {}) else output = stdout + -- trim trailing \r in every line + -- so that both branches of this if block behaves the same + for i, line in ipairs(output) do + output[i] = string.gsub(line, "\r$", "") + end end -- Remove the trailing newline from the output to convert back to vim lines representation if add_extra_newline and output[#output] == "" then -- cgit v1.2.3-70-g09d2