Skip to content

Commit 42fdd36

Browse files
committed
rip out update_depth again.
I don't think that this is a good idea, at least currently, where I don't yet have a good feel for the way self-dependent dynamicNodes are going to be used. Difficulties: picking a good default depth. Even something as outwardly innocuous as 100 is bad when applied to a snippet that doubles some character. On the other hand, this can totally kill "chains" of updates, where some inner snippet updates text that is suddenly changed by an outer snippet... So, for now, I'm putting this down as user error, and even though having to kill your nvim-instance because it is caught in an infinite loop is not great at all, it shouldn't occur to often, and all ways around this I can think of may impede absolutely valid usage of dynamicNodes.
1 parent 5c2225e commit 42fdd36

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

lua/luasnip/nodes/dynamicNode.lua

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ local log = require("luasnip.util.log").new("dynamicNode")
1212
local describe = require("luasnip.util.log").describe
1313
local session = require("luasnip.session")
1414

15-
local update_depth_limit = 100
16-
1715
local function D(pos, fn, args, opts)
1816
opts = opts or {}
1917

@@ -190,26 +188,6 @@ function DynamicNode:update()
190188
old_state = self.snip.old_state
191189
end
192190

193-
-- set `last_args` here, prevents additional updates after update_depth was
194-
-- exceeded.
195-
self.last_args = str_args
196-
197-
local reset_depth = false
198-
if not session.update_depths[self] then
199-
session.update_depths[self] = 1
200-
reset_depth = true
201-
elseif session.update_depths[self] < update_depth_limit then
202-
session.update_depths[self] = session.update_depths[self] + 1
203-
elseif self.snip then
204-
-- only skip updates if the snippet is already generated!!
205-
log.error(
206-
"Skipping update of %s because the number of nested updates exceeded %s. Traceback: %s",
207-
describe.node(self),
208-
update_depth_limit,
209-
describe.traceback())
210-
return
211-
end
212-
213191
-- build new snippet before exiting, markers may be needed for
214192
-- construncting.
215193
tmp = self.fn(
@@ -231,7 +209,9 @@ function DynamicNode:update()
231209
self:focus()
232210
end
233211

234-
log.debug("updating %s (depth: %s)", describe.node(self), session.update_depths[self])
212+
log.debug("updating %s", describe.node(self))
213+
214+
self.last_args = str_args
235215

236216
-- act as if snip is directly inside parent.
237217
tmp.parent = self.parent
@@ -290,10 +270,6 @@ function DynamicNode:update()
290270
-- children's depedents (since they may have dependents outside this
291271
-- dynamicNode, who have not yet been updated)
292272
self:update_dependents({ own = true, children = true, parents = true })
293-
294-
if reset_depth then
295-
session.update_depths[self] = nil
296-
end
297273
end
298274

299275
local update_errorstring = [[

lua/luasnip/session/init.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,4 @@ function M.get_snip_env()
5555
return M.config.snip_env
5656
end
5757

58-
M.update_depths = {}
59-
6058
return M

0 commit comments

Comments
 (0)