mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-08-23 10:48:20 +02:00
fix(snippet): always use top-level snippet session. Fixes #3199
This commit is contained in:
parent
59204df1cb
commit
53911748dd
1 changed files with 12 additions and 0 deletions
|
@ -86,6 +86,13 @@ function M.confirm(opts)
|
|||
end
|
||||
|
||||
function M.expand(snippet)
|
||||
-- Native sessions don't support nested snippet sessions.
|
||||
-- Always use the top-level session.
|
||||
-- Otherwise, when on the first placeholder and selecting a new completion,
|
||||
-- the nested session will be used instead of the top-level session.
|
||||
-- See: https://github.com/LazyVim/LazyVim/issues/3199
|
||||
local session = vim.snippet.active() and vim.snippet._session or nil
|
||||
|
||||
local ok = pcall(vim.snippet.expand, snippet)
|
||||
if not ok then
|
||||
local fixed = M.snippet_fix(snippet)
|
||||
|
@ -101,6 +108,11 @@ function M.expand(snippet)
|
|||
{ title = "vim.snippet" }
|
||||
)
|
||||
end
|
||||
|
||||
-- Restore top-level session when needed
|
||||
if session then
|
||||
vim.snippet._session = session
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue