mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
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:
parent
d72e82d3db
commit
5e64d65df6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user