summaryrefslogtreecommitdiff
path: root/lua/clever_f/acquisition_service.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/acquisition_service.lua')
-rw-r--r--lua/clever_f/acquisition_service.lua34
1 files changed, 29 insertions, 5 deletions
diff --git a/lua/clever_f/acquisition_service.lua b/lua/clever_f/acquisition_service.lua
index a19f8f8..5cbe6ab 100644
--- a/lua/clever_f/acquisition_service.lua
+++ b/lua/clever_f/acquisition_service.lua
@@ -321,23 +321,47 @@ function TemporaryResourceScope:release()
if record == nil then
fail("temporary resource scope is invalid", 2)
end
+ if not record.active then
+ return false
+ end
+ record.active = false
+
+ local first_error
+ local function release_operation(operation)
+ local ok, failure = pcall(operation)
+ if not ok and first_error == nil then
+ first_error = failure
+ end
+ end
+
if record.interactive
and record.prompt_shown
and record.input_completed
and record.acquisition_completed
then
- record.host:redraw("full")
+ release_operation(function()
+ record.host:redraw("full")
+ end)
end
if record.direct_marker ~= nil then
- record.feedback:remove_temporary_overlay(record.direct_marker)
+ release_operation(function()
+ record.feedback:remove_temporary_overlay(record.direct_marker)
+ end)
end
if record.cursor_marker ~= nil then
- record.feedback:remove_temporary_overlay(record.cursor_marker)
+ release_operation(function()
+ record.feedback:remove_temporary_overlay(record.cursor_marker)
+ end)
end
if record.cursor_presentation_lease ~= nil then
- record.cursor_presentation_lease:release()
+ release_operation(function()
+ record.cursor_presentation_lease:release()
+ end)
end
- record.active = false
+ if first_error ~= nil then
+ error(first_error, 0)
+ end
+ return true
end
local function require_policy(service, host)