summaryrefslogtreecommitdiff
path: root/lua/99/ops/clean-up.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/99/ops/clean-up.lua')
-rw-r--r--lua/99/ops/clean-up.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/lua/99/ops/clean-up.lua b/lua/99/ops/clean-up.lua
index 56a7e11..9eea6da 100644
--- a/lua/99/ops/clean-up.lua
+++ b/lua/99/ops/clean-up.lua
@@ -7,10 +7,10 @@ local M = {}
--- @field on_stderr? fun(line: string): nil
--- @field on_start? fun(): nil
---- @param clean_up fun(): nil
+--- @param context _99.Prompt
--- @param obs_or_fn _99.Providers.PartialObserver | _99.Providers.on_complete
--- @return _99.Providers.Observer
-M.make_observer = function(clean_up, obs_or_fn)
+M.make_observer = function(context, obs_or_fn)
--- @type _99.Providers.PartialObserver
local obs = type(obs_or_fn) == "table" and obs_or_fn
or {
@@ -23,8 +23,11 @@ M.make_observer = function(clean_up, obs_or_fn)
end
end,
on_complete = function(status, res)
- vim.schedule(clean_up)
- obs.on_complete(status, res)
+ pcall(obs.on_complete, status, res)
+ vim.schedule(function()
+ context:stop()
+ context._99:sync()
+ end)
end,
on_stderr = function(line)
if obs.on_stderr then