Normalize source line endings when loading classfile contents

This commit is contained in:
Joao Sa 2023-11-18 15:10:45 +01:00 committed by Mathias Fußenegger
parent 503a399e0d
commit 44403b2ef6

View file

@ -1190,7 +1190,9 @@ function M.open_classfile(fname)
local function handler(err, result)
assert(not err, vim.inspect(err))
content = result
api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result, "\n", { plain = true }))
local normalized = string.gsub(result, '\r\n', '\n')
local source_lines = vim.split(normalized, "\n", { plain = true })
api.nvim_buf_set_lines(buf, 0, -1, false, source_lines)
vim.bo[buf].modifiable = false
end