Skip to content

Commit

Permalink
set jump_active=false ASAP.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Nov 5, 2024
1 parent 1d7577c commit 15ebd05
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lua/luasnip/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions lua/luasnip/util/feedkeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/session_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2246,9 +2246,6 @@ describe("session", function()
{2:-- INSERT --recording @a} |]],
})
feed("cc<Esc>Gqo<Esc>@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 = [[
/** |
Expand All @@ -2267,7 +2264,7 @@ describe("session", function()
* |
* @return |
* |
* @throws |
* @throws cc |
*/ |
private aa bb() {4:●} |
throws cc { |
Expand Down

0 comments on commit 15ebd05

Please sign in to comment.