diff --git a/lua/luasnip/init.lua b/lua/luasnip/init.lua index 99ddf47f5..260cb28a3 100644 --- a/lua/luasnip/init.lua +++ b/lua/luasnip/init.lua @@ -20,12 +20,14 @@ local log = require("luasnip.util.log").new("main") local function no_region_check_wrap(fn, ...) session.jump_active = true - -- will run on next tick, after autocommands (especially CursorMoved) for this are done. - vim.schedule(function() + local fn_res = fn(...) + -- once all movements and text-modifications (and autocommands triggered by + -- these) are done, we can set jump_active false, and allow the various + -- autocommands to change luasnip-state again. + feedkeys.enqueue_action(function() session.jump_active = false end) - local fn_res = fn(...) return fn_res end diff --git a/lua/luasnip/util/feedkeys.lua b/lua/luasnip/util/feedkeys.lua index b6d125eda..022c4d45e 100644 --- a/lua/luasnip/util/feedkeys.lua +++ b/lua/luasnip/util/feedkeys.lua @@ -58,6 +58,13 @@ local function enqueue_action(fn, keys_id) end end +function M.enqueue_action(fn) + enqueue_action(function(id) + fn() + M.confirm(id) + end, next_id()) +end + function M.feedkeys_insert(keys) enqueue_action(function(id) _feedkeys_insert(id, keys) diff --git a/tests/integration/session_spec.lua b/tests/integration/session_spec.lua index 7a8b4cd92..acb84bcec 100644 --- a/tests/integration/session_spec.lua +++ b/tests/integration/session_spec.lua @@ -2246,9 +2246,6 @@ describe("session", function() {2:-- INSERT --recording @a} |]], }) feed("ccGqo@a") - -- this is not entirely correct!! - -- The autocommand that updated the docstring ("cc") of the original - -- snippet is disabled in the replayed snippet because. screen:expect({ grid = [[ /** | @@ -2267,7 +2264,7 @@ describe("session", function() * | * @return | * | - * @throws | + * @throws cc | */ | private aa bb() {4:●} | throws cc { |