mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
fix(editorconfig): do not set 'endofline'
Problem:
'endofline' can be used to detect if a file ends of <EOL>, however
editorconfig can break this.
Solution:
Set 'endofline' during BufWritePre
Fixes: #24869
(cherry picked from commit 84376afc72)
This commit is contained in:
committed by
github-actions[bot]
parent
b30896bbaf
commit
9f928902c7
@@ -111,7 +111,20 @@ end
|
||||
function M.properties.insert_final_newline(bufnr, val)
|
||||
assert(val == 'true' or val == 'false', 'insert_final_newline must be either "true" or "false"')
|
||||
vim.bo[bufnr].fixendofline = val == 'true'
|
||||
vim.bo[bufnr].endofline = val == 'true'
|
||||
|
||||
-- 'endofline' can be read to detect if the file contains a final newline,
|
||||
-- so only change 'endofline' right before writing the file
|
||||
local endofline = val == 'true'
|
||||
if vim.bo[bufnr].endofline ~= endofline then
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = 'editorconfig',
|
||||
buffer = bufnr,
|
||||
once = true,
|
||||
callback = function()
|
||||
vim.bo[bufnr].endofline = endofline
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
--- Modified version of |glob2regpat()| that does not match path separators on *.
|
||||
|
||||
Reference in New Issue
Block a user