You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.
Log file
before my fix
22:50:06[DEBUG] Running formatters on D:\projects\conform-prettier-crlf-reproduce-bug\index.html: { "prettier" }
22:50:06[INFO] Run prettier on D:\projects\conform-prettier-crlf-reproduce-bug\index.html
22:50:06[TRACE] Input lines: { "<body>", " <div></div>", "</body>" }
22:50:06[DEBUG] Run command: { "prettier.cmd", "--stdin-filepath", "D:\\projects\\conform-prettier-crlf-reproduce-bug\\index.html" }
22:50:06[DEBUG] Run CWD: D:/projects/conform-prettier-crlf-reproduce-bug
22:50:06[DEBUG] prettier exited with code 0
22:50:06[TRACE] Output lines: { "<body>\r", " <div></div>\r", "</body>\r" }
22:50:06[TRACE] prettier stderr: { "" }
22:50:06[TRACE] Applying formatting to D:\projects\conform-prettier-crlf-reproduce-bug\index.html
22:50:06[TRACE] Comparing lines { "<body>", " <div></div>", "</body>" } and { "<body>\r", " <div></div>\r", "</body>\r" }
22:50:06[TRACE] Diff indices { { 1, 3, 1, 3 } }
22:50:06[TRACE] Applying text edits: { {
newText = "\r\n <div></div>\r\n</body>\r",
range = {
["end"] = {
character = 7,
line = 2
},
start = {
character = 6,
line = 0
}
}
} }
22:50:06[TRACE] Done formatting D:\projects\conform-prettier-crlf-reproduce-bug\index.html
after my fix
22:50:03[DEBUG] Running formatters on D:\projects\conform-prettier-crlf-reproduce-bug\index.html: { "prettier" }
22:50:03[INFO] Run prettier on D:\projects\conform-prettier-crlf-reproduce-bug\index.html
22:50:03[TRACE] Input lines: { "<body>", " <div></div>", "</body>" }
22:50:03[DEBUG] Run command: { "prettier.cmd", "--stdin-filepath", "D:\\projects\\conform-prettier-crlf-reproduce-bug\\index.html" }
22:50:03[DEBUG] Run CWD: D:/projects/conform-prettier-crlf-reproduce-bug
22:50:04[DEBUG] prettier exited with code 0
22:50:04[TRACE] Output lines: { "<body>", " <div></div>", "</body>" }
22:50:04[TRACE] prettier stderr: { "" }
22:50:04[TRACE] Applying formatting to D:\projects\conform-prettier-crlf-reproduce-bug\index.html
22:50:04[TRACE] Comparing lines { "<body>", " <div></div>", "</body>" } and { "<body>", " <div></div>", "</body>" }
22:50:04[TRACE] Diff indices {}
22:50:04[TRACE] Applying text edits: {}
22:50:04[TRACE] Done formatting D:\projects\conform-prettier-crlf-reproduce-bug\index.html
Describe the bug
when format a html file with the prettier formatter, an empty line is unexpected appended to the file after running conform formatting.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
create a .prettierrc.json with content {"endOfLine": "crlf"}
create a html fie with content <body>\r\n<div></div>\r\n</body>
trigger a conform format with :w
Expected Behavior
Nothing should be changed by prettier however actual behaviour is that an empty line is append to the html file.
Minimal example file
Minimal init.lua
-- DO NOT change the paths and don't remove the colorschemelocalroot=vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .reprofor_, nameinipairs({ "config", "data", "state", "cache" }) dovim.env[("XDG_%s_HOME"):format(name:upper())] =root.."/" ..nameend-- bootstrap lazylocallazypath=root.."/plugins/lazy.nvim"ifnotvim.loop.fs_stat(lazypath) thenvim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
endvim.opt.runtimepath:prepend(lazypath)
-- install pluginslocalplugins= {
"folke/tokyonight.nvim",
{
"stevearc/conform.nvim",
config=function()
require("conform").setup({
log_level=vim.log.levels.TRACE,
notify_on_error=false,
format_on_save=function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't-- have a well standardized coding style. You can add additional-- languages here or re-enable it for the disabled ones.localdisable_filetypes= { c=true, cpp=true }
return {
timeout_ms=500,
lsp_fallback=notdisable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft= {
lua= { 'stylua' },
html= { 'prettier' },
-- Conform can also run multiple formatters sequentially-- python = { "isort", "black" },---- You can use a sub-list to tell conform to run *until* a formatter-- is found.javascript= { 'prettier' },
typescript= { 'prettier' },
},
})
end,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root=root.."/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
Additional context
When fixing #274 in commit 9a785eb in file lua/conform/runner.lua, \r\n eol is handled in one branch of the if block so that no elements output end with \r. My fix ensures that this behaviour is consistent in both branches.
The text was updated successfully, but these errors were encountered:
Neovim version (nvim -v)
nvim 0.9.5
Operating system/version
Windows 11
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
before my fix
after my fix
Describe the bug
when format a html file with the prettier formatter, an empty line is unexpected appended to the file after running conform formatting.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
.prettierrc.json
with content{"endOfLine": "crlf"}
<body>\r\n<div></div>\r\n</body>
:w
Expected Behavior
Nothing should be changed by prettier however actual behaviour is that an empty line is append to the html file.
Minimal example file
Minimal init.lua
Additional context
When fixing #274 in commit 9a785eb in file
lua/conform/runner.lua
,\r\n
eol is handled in one branch of the if block so that no elementsoutput
end with\r
. My fix ensures that this behaviour is consistent in both branches.The text was updated successfully, but these errors were encountered: