fix(filetype): make sure buffer is valid before call nvim_buf_call (#24922)

This commit is contained in:
Hongbo Liu 2023-08-30 11:14:58 -04:00 committed by GitHub
parent bec13cfcaf
commit 670c7609c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,9 @@ vim.api.nvim_create_augroup('filetypedetect', { clear = false })
vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'StdinReadPost' }, {
group = 'filetypedetect',
callback = function(args)
if not vim.api.nvim_buf_is_valid(args.buf) then
return
end
local ft, on_detect = vim.filetype.match({ filename = args.match, buf = args.buf })
if not ft then
-- Generic configuration file used as fallback