aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongbo Liu <hongboliu@tencent.com>2023-08-30 11:14:58 -0400
committerGitHub <noreply@github.com>2023-08-30 10:14:58 -0500
commit670c7609c85547ef041af8cf17139a396d6af050 (patch)
treef2a802bd0c789ba2692bbfaca8315a50966d363e
parentbec13cfcafe73d33ed707b690fd924b1f52241f8 (diff)
downloadrneovim-670c7609c85547ef041af8cf17139a396d6af050.tar.gz
rneovim-670c7609c85547ef041af8cf17139a396d6af050.tar.bz2
rneovim-670c7609c85547ef041af8cf17139a396d6af050.zip
fix(filetype): make sure buffer is valid before call nvim_buf_call (#24922)
-rw-r--r--runtime/filetype.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/filetype.lua b/runtime/filetype.lua
index 4a4f37a1c4..3f2a7c2960 100644
--- a/runtime/filetype.lua
+++ b/runtime/filetype.lua
@@ -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