From c4fc7e629e8ea7ecc9610107622f46e888764534 Mon Sep 17 00:00:00 2001 From: champignoom Date: Wed, 27 Dec 2023 11:15:00 +0800 Subject: [PATCH] feat(toc): don't scroll content window when switching to toc --- lua/neorg/modules/core/qol/toc/module.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/neorg/modules/core/qol/toc/module.lua b/lua/neorg/modules/core/qol/toc/module.lua index a59b48a30..fc2efb91a 100644 --- a/lua/neorg/modules/core/qol/toc/module.lua +++ b/lua/neorg/modules/core/qol/toc/module.lua @@ -451,6 +451,14 @@ module.on_event = function(event) -- Sync cursor: ToC -> content if module.config.public.sync_cursorline then + -- Ignore the first (fake) CursorMoved coming together with BufEnter of the ToC buffer + vim.api.nvim_create_autocmd("BufEnter", { + buffer = ui_data.buffer, + callback = function(_ev) + ui_data.cursor_start_moving = false + end, + }) + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { buffer = ui_data.buffer, callback = function(ev)