diff --git a/runtime/lua/vim/secure.lua b/runtime/lua/vim/secure.lua index de744ed008..2b40048d71 100644 --- a/runtime/lua/vim/secure.lua +++ b/runtime/lua/vim/secure.lua @@ -1,5 +1,11 @@ local M = {} +local fileformat_newlines = { + unix = '\n', + dos = '\r\n', + mac = '\r', +} + --- Reads trust database from $XDG_STATE_HOME/nvim/trust. --- ---@return table Contents of trust database, if it exists. Empty table otherwise. @@ -45,7 +51,7 @@ local function compute_hash(fullpath, bufnr) if is_unchanged_empty then contents = '' else - local newline = vim.bo[bufnr].fileformat == 'unix' and '\n' or '\r\n' + local newline = fileformat_newlines[vim.bo[bufnr].fileformat] contents = table.concat(vim.api.nvim_buf_get_lines(bufnr --[[@as integer]], 0, -1, false), newline) if vim.bo[bufnr].endofline then