Skip to content

Commit 15ebd05

Browse files
committed
set jump_active=false ASAP.
1 parent 1d7577c commit 15ebd05

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lua/luasnip/init.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ local log = require("luasnip.util.log").new("main")
2020

2121
local function no_region_check_wrap(fn, ...)
2222
session.jump_active = true
23-
-- will run on next tick, after autocommands (especially CursorMoved) for this are done.
24-
vim.schedule(function()
23+
local fn_res = fn(...)
24+
-- once all movements and text-modifications (and autocommands triggered by
25+
-- these) are done, we can set jump_active false, and allow the various
26+
-- autocommands to change luasnip-state again.
27+
feedkeys.enqueue_action(function()
2528
session.jump_active = false
2629
end)
2730

28-
local fn_res = fn(...)
2931
return fn_res
3032
end
3133

lua/luasnip/util/feedkeys.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ local function enqueue_action(fn, keys_id)
5858
end
5959
end
6060

61+
function M.enqueue_action(fn)
62+
enqueue_action(function(id)
63+
fn()
64+
M.confirm(id)
65+
end, next_id())
66+
end
67+
6168
function M.feedkeys_insert(keys)
6269
enqueue_action(function(id)
6370
_feedkeys_insert(id, keys)

tests/integration/session_spec.lua

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,9 +2246,6 @@ describe("session", function()
22462246
{2:-- INSERT --recording @a} |]],
22472247
})
22482248
feed("cc<Esc>Gqo<Esc>@a")
2249-
-- this is not entirely correct!!
2250-
-- The autocommand that updated the docstring ("cc") of the original
2251-
-- snippet is disabled in the replayed snippet because.
22522249
screen:expect({
22532250
grid = [[
22542251
/** |
@@ -2267,7 +2264,7 @@ describe("session", function()
22672264
* |
22682265
* @return |
22692266
* |
2270-
* @throws |
2267+
* @throws cc |
22712268
*/ |
22722269
private aa bb() {4:●} |
22732270
throws cc { |

0 commit comments

Comments
 (0)