diff options
author | Li BingMuyou <77159535+li6in9muyou@users.noreply.github.com> | 2024-04-14 06:01:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 15:01:39 -0700 |
commit | 820eec990d5f332d30cf939954c8672a43a0459e (patch) | |
tree | df42e237d42aadd25f8849630db0e8fef55b0be1 /lua/conform | |
parent | 500a6ae6c10b2a96e85e64045ad9f3b16e2af7f8 (diff) |
fix: handle windows line ending when config.stdin is true (#361)
Diffstat (limited to 'lua/conform')
-rw-r--r-- | lua/conform/runner.lua | 5 |
1 files changed, 5 insertions, 0 deletions
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 |