From 1b86d7b2ade1dc934165fb1de8e5a3b211bc5ee0 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 28 May 2024 19:32:21 +0200 Subject: [PATCH] fix(snippets): fix snippets with multiple placeholders for the same tabstop --- lua/lazyvim/util/cmp.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/util/cmp.lua b/lua/lazyvim/util/cmp.lua index a3f83d79..e4a7f700 100644 --- a/lua/lazyvim/util/cmp.lua +++ b/lua/lazyvim/util/cmp.lua @@ -28,10 +28,10 @@ end -- This function replaces nested placeholders in a snippet with LSP placeholders. function M.snippet_fix(snippet) - local nn = 0 + local texts = {} ---@type table return M.snippet_replace(snippet, function(placeholder) - nn = nn + 1 - return "${" .. nn .. ":" .. M.snippet_preview(placeholder.text) .. "}" + texts[placeholder.n] = texts[placeholder.n] or M.snippet_preview(placeholder.text) + return "${" .. placeholder.n .. ":" .. texts[placeholder.n] .. "}" end) end