From 3e30ca80c06def35f992c322425e69735c9b5913 Mon Sep 17 00:00:00 2001 From: L3MON4D3 Date: Tue, 29 Oct 2024 16:17:47 +0100 Subject: [PATCH] snippet: correctly propagate exit to child_snippets (and clear them). --- lua/luasnip/nodes/snippet.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/luasnip/nodes/snippet.lua b/lua/luasnip/nodes/snippet.lua index d24aec1f5..706caad5a 100644 --- a/lua/luasnip/nodes/snippet.lua +++ b/lua/luasnip/nodes/snippet.lua @@ -1133,12 +1133,12 @@ end function Snippet:exit() if self.type == types.snippet then - -- if exit is called, this will not be visited again. - -- Thus, also clean up the child-snippets, which will also not be - -- visited again, since they can only be visited through self. - for _, child in ipairs(self.child_snippets) do - child:exit() + -- insertNode also call exit for their child_snippets, but if we + -- :exit() the whole snippet we can just remove all of them here. + for _, snip in ipairs(self.child_snippets) do + snip:exit() end + self.child_snippets = {} end self.visible = false