[Backport release-0.9] fix(filetype): make sure buffer is valid before call nvim_buf_call (#24950)

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

(cherry picked from commit c3e611694e)

Co-authored-by: HongboLiu <lhbf@qq.com>
This commit is contained in:
github-actions[bot]
2023-08-30 12:21:01 -05:00
committed by GitHub
parent 033059e781
commit fec20ce15c

View File

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