From 71291ef97292abe94892151b6b848a59ac5d6639 Mon Sep 17 00:00:00 2001 From: champignoom Date: Thu, 30 Nov 2023 02:14:10 +0800 Subject: [PATCH] fix(toc): listen cursormoved for all norg files --- lua/neorg/modules/core/qol/toc/module.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/neorg/modules/core/qol/toc/module.lua b/lua/neorg/modules/core/qol/toc/module.lua index abadef3dc..368bc195e 100644 --- a/lua/neorg/modules/core/qol/toc/module.lua +++ b/lua/neorg/modules/core/qol/toc/module.lua @@ -402,13 +402,16 @@ module.on_event = function(event) if module.config.public.sync_cursorline then vim.api.nvim_create_autocmd({"CursorMoved", "CursorMovedI"}, { - buffer = previous_buffer, + pattern = "*.norg", callback = function(ev) - assert(ev.buf == previous_buffer) if not vim.api.nvim_buf_is_valid(buffer) or not vim.api.nvim_buf_is_loaded(buffer) then return true end + if ev.buf ~= previous_buffer then + return + end + module.public.update_cursor(ev.buf, vim.fn.bufwinid(ev.buf), buffer, window) end, })