mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00: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:
@@ -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
|
||||
|
Reference in New Issue
Block a user