Skip to content

Commit a1a60eb

Browse files
committed
refactor: link snippet with end_ and start_node in trigger_expand.
If jumplist_insert is configurable, we should clean this up a bit. IMO it might be expected that the links between a snippets and its i(0), i(-1) exist, so we'll just add them. If this is not desired, they can still be overridden easily.
1 parent 03fb957 commit a1a60eb

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lua/luasnip/nodes/snippet.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,6 @@ local function insert_into_jumplist(snippet, start_node, end_node, current_node)
422422
start_node.prev = current_node
423423
end
424424
end
425-
426-
-- snippet is between i(-1)(startNode) and i(0).
427-
snippet.next = end_node
428-
snippet.prev = start_node
429-
430-
end_node.prev = snippet
431-
start_node.next = snippet
432425
end
433426

434427
function Snippet:trigger_expand(current_node, pos_id, env, jumplist_insert_func)
@@ -509,6 +502,12 @@ function Snippet:trigger_expand(current_node, pos_id, env, jumplist_insert_func)
509502
start_node.pos = -1
510503
start_node.parent = self
511504

505+
-- snippet is between i(-1)(startNode) and i(0).
506+
self.insert_nodes[0].prev = self
507+
start_node.next = self
508+
self.next = self.insert_nodes[0]
509+
self.prev = start_node
510+
512511
jumplist_insert_func(self, start_node, self.insert_nodes[0], current_node)
513512
end
514513

0 commit comments

Comments
 (0)