Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle windows line ending when config.stdin is true #361

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lua/conform/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading