-
Notifications
You must be signed in to change notification settings - Fork 161
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(black): formatting excluded files results in blank buffer (#249) #254
Fix(black): formatting excluded files results in blank buffer (#249) #254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach looks good, but the fuzz tester is failing. You may need to adjust the fuzz tester to not trigger this condition
lua/conform/runner.lua
Outdated
if new_text:match("^%s*$") and not original_text:match("^%s*$") then | ||
log.trace("Aborting because a formatter returned empty output") | ||
return | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a fine place for it, but I'd say add the buffer name to the log line and make it a warn
instead of a trace
tests/runner_spec.lua
Outdated
local original_lines = { "line one", "line two" } | ||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, original_lines) | ||
vim.bo[bufnr].modified = false | ||
test_util.set_formatter_output({ "" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently made a change the moved this out of test_util
. You may need to rework the test a bit.
Thanks for the PR! |
Thanks! This helped me with the I'll try to figure out why that happens and report it later on, but now I can get back to work. ❤️ |
Fixes #249
This fix checks for blank formatter output in
apply_format
. Not sure if this is the best place to apply this fix, but seemed the most obvious place since it'll work the same for both sync and async formats