mirror of
https://github.com/L3MON4D3/LuaSnip
synced 2024-09-16 21:54:03 +02:00
vscode-loader: don't error on cleanup (close #1163).
This commit is contained in:
parent
03c8e67eb7
commit
f8eb1e7d1c
2 changed files with 26 additions and 4 deletions
|
@ -325,16 +325,16 @@ function Collection.new(
|
|||
end
|
||||
end
|
||||
|
||||
local watcher_ok, err = pcall(path_watcher, manifest_path, {
|
||||
local ok, watcher_or_err = pcall(path_watcher, manifest_path, {
|
||||
-- don't handle removals for now.
|
||||
add = update_manifest,
|
||||
change = update_manifest,
|
||||
}, { lazy = lazy_watcher, fs_event_providers = fs_event_providers })
|
||||
|
||||
if not watcher_ok then
|
||||
error(("Could not create watcher: %s"):format(err))
|
||||
if not ok then
|
||||
error(("Could not create watcher: %s"):format(watcher_or_err))
|
||||
end
|
||||
o.manifest_watcher = watcher_ok
|
||||
o.manifest_watcher = watcher_or_err
|
||||
|
||||
log.info("Initialized snippet-collection with manifest %s", manifest_path)
|
||||
|
||||
|
|
|
@ -112,6 +112,28 @@ describe("loaders:", function()
|
|||
)
|
||||
end)
|
||||
|
||||
for_all_loaders("removes all snippets when cleanup is called.", function()
|
||||
-- make sure the loader worked.
|
||||
feed("iall1")
|
||||
exec_lua("ls.expand()")
|
||||
screen:expect({
|
||||
grid = [[
|
||||
expands? jumps? ^ ! |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{2:-- INSERT --} |]],
|
||||
})
|
||||
|
||||
exec_lua("ls.cleanup()")
|
||||
feed("<Esc>ccall1")
|
||||
exec_lua("ls.expand()")
|
||||
screen:expect({grid = [[
|
||||
all1^ |
|
||||
{0:~ }|*3
|
||||
{2:-- INSERT --} |]]})
|
||||
end)
|
||||
|
||||
it("Can lazy-load from multiple sources", function()
|
||||
ls_helpers.loaders["snipmate(lazy)"]("snippets")
|
||||
ls_helpers.loaders["vscode(lazy)"]()
|
||||
|
|
Loading…
Reference in a new issue