From 369ed28b0b0c3f221b46816ad53a509d73c7e7ed Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Tue, 25 Jun 2024 12:51:55 -0400 Subject: [PATCH] fix(todo-introspector): check that the buffer is valid --- lua/neorg/modules/core/todo-introspector/module.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/neorg/modules/core/todo-introspector/module.lua b/lua/neorg/modules/core/todo-introspector/module.lua index 5d7d5907c..7d5806356 100644 --- a/lua/neorg/modules/core/todo-introspector/module.lua +++ b/lua/neorg/modules/core/todo-introspector/module.lua @@ -62,6 +62,9 @@ function module.public.attach_introspector(buffer) vim.api.nvim_buf_attach(buffer, false, { on_lines = vim.schedule_wrap(function(_, buf, _, first) + if not vim.api.nvim_buf_is_valid(buf) then + return + end -- If we delete the last line of a file `first` will point to a nonexistent line -- For this reason we fall back to the line count (accounting for 0-based indexing) -- whenever a change to the document is made.