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:
ESSO0428
2025-03-18 10:43:22 +08:00
committed by GitHub
parent 4384a8ddca
commit 6fc4f16a4e

View File

@@ -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