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.
This commit is contained in:
Jared Weakly 2022-03-25 11:12:00 -07:00 committed by GitHub
parent d72e82d3db
commit 5e64d65df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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