commit 5e64d65df690000e56fd91577978e1744d6e9e8e
parent d72e82d3dba10c54c0de79c0fa43da7f71345a91
Author: Jared Weakly <jaredweakly@gmail.com>
Date: Fri, 25 Mar 2022 11:12:00 -0700
fix(filetype.lua): always return a string in getline helper function (#17852)
Uses of `getline` in `filetype.lua` currently assume it always returns a
string. However, if the buffer is unloaded when filetype detection runs,
`getline` returns `nil`. Fixing this prevents errors when filetype
detection is run on unloaded buffers.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
@@ -21,7 +21,7 @@ end
---@private
local function getline(bufnr, lnum)
- return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1]
+ return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] or ""
end
-- Filetypes based on file extension