fix: normalize CRLF to LF in read_file_from_buf_or_disk (#1622)
Ensure consistent line endings when reading files by converting CRLF (`\r\n`) to LF (`\n`). This fixes incorrect line number detection when modifying CRLF-formatted files. Addresses yetone/avante.nvim#1621.
This commit is contained in:
@@ -1079,6 +1079,7 @@ function M.read_file_from_buf_or_disk(filepath)
|
||||
if file then
|
||||
local content = file:read("*all")
|
||||
file:close()
|
||||
content = content:gsub("\r\n", "\n")
|
||||
return vim.split(content, "\n"), nil
|
||||
else
|
||||
return {}, open_err
|
||||
|
||||
Reference in New Issue
Block a user