Skip to content

Commit f3c95f3

Browse files
committed
don't modify jumplist-insertion too much, does not match some assumptions.
In particular, snip.next.next of a i(0), or snip.prev.prev of a i(-1) is often assumed to be the next/previous snippet, which is not the case if we do the modifications from the parent. Instead: just modify behaviour of i(-1), such that it is just ignored while jumping.
1 parent 339840f commit f3c95f3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lua/luasnip/extras/lsp.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,26 @@ function M.apply_text_edits(snippet_or_text_edits, bufnr, offset_encoding, apply
102102
expand_opts.jump_into_func = function(snip)
103103
expanded_snippets[i] = snip
104104
local cr = _jump_into_default(snip)
105-
print(cr)
106105
return cr
107106
end
108107
else
109108
-- don't jump into the snippet, just store it.
110109
expand_opts.jump_into_func = function(snip)
111110
expanded_snippets[i] = snip
112111

113-
print(session.current_nodes[bufnr])
114-
115112
-- let the already-active node stay active.
116113
return session.current_nodes[bufnr]
117114
end
118-
-- jump from previous i0 directly into this snippet (ignore start_node).
119-
expand_opts.jumplist_insert_func = function(snippet, _, _, _)
120-
snippet.prev = expanded_snippets[i-1].insert_nodes[0]
121-
expanded_snippets[i-1].insert_nodes[0].next = snippet
115+
-- jump from previous i0 directly to start_node.
116+
expand_opts.jumplist_insert_func = function(_, start_node, _, _)
117+
start_node.prev = expanded_snippets[i-1].insert_nodes[0]
118+
expanded_snippets[i-1].insert_nodes[0].next = start_node
119+
120+
-- skip start_node while jumping around.
121+
-- start_node of first snippet behaves normally!
122+
function start_node:jump_into(dir, no_move)
123+
return (dir == 1 and self.next or self.prev):jump_into(dir, no_move)
124+
end
122125
end
123126
end
124127

0 commit comments

Comments
 (0)