From cefe44f5870ea02ab5ba6205d692cf87d5ed4b16 Mon Sep 17 00:00:00 2001 From: Iron-E <36409591+Iron-E@users.noreply.github.com> Date: Mon, 15 May 2023 19:21:58 +0000 Subject: [PATCH] fix(events): attempt to operate on invalid buffer (#490) --- lua/barbar/events.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/barbar/events.lua b/lua/barbar/events.lua index 6737ef62..d367c20b 100644 --- a/lua/barbar/events.lua +++ b/lua/barbar/events.lua @@ -4,6 +4,7 @@ local table_insert = table.insert local buf_call = vim.api.nvim_buf_call --- @type function local buf_get_name = vim.api.nvim_buf_get_name --- @type function local buf_get_option = vim.api.nvim_buf_get_option --- @type function +local buf_is_valid = vim.api.nvim_buf_is_valid --- @type function local buf_set_var = vim.api.nvim_buf_set_var --- @type function local command = vim.api.nvim_command --- @type function local create_augroup = vim.api.nvim_create_augroup --- @type function @@ -79,9 +80,11 @@ function events.enable() create_autocmd({'BufNewFile', 'BufReadPost'}, { callback = vim.schedule_wrap(function(event) - jump_mode.assign_next_letter(event.buf) - state.update_diagnostics(event.buf) - state.update_gitsigns(event.buf) + if buf_is_valid(event.buf) then + jump_mode.assign_next_letter(event.buf) + state.update_diagnostics(event.buf) + state.update_gitsigns(event.buf) + end end), group = augroup_misc, })