Use new CommandView:enter options table
This commit is contained in:
+15
-12
@@ -65,19 +65,22 @@ end
|
||||
function DocView:try_close(do_close)
|
||||
if self.doc:is_dirty()
|
||||
and #core.get_views_referencing_doc(self.doc) == 1 then
|
||||
core.command_view:enter("Unsaved Changes; Confirm Close", function(_, item)
|
||||
if item.text:match("^[cC]") then
|
||||
do_close()
|
||||
elseif item.text:match("^[sS]") then
|
||||
self.doc:save()
|
||||
do_close()
|
||||
core.command_view:enter("Unsaved Changes; Confirm Close", {
|
||||
submit = function(_, item)
|
||||
if item.text:match("^[cC]") then
|
||||
do_close()
|
||||
elseif item.text:match("^[sS]") then
|
||||
self.doc:save()
|
||||
do_close()
|
||||
end
|
||||
end,
|
||||
suggest = function(text)
|
||||
local items = {}
|
||||
if not text:find("^[^cC]") then table.insert(items, "Close Without Saving") end
|
||||
if not text:find("^[^sS]") then table.insert(items, "Save And Close") end
|
||||
return items
|
||||
end
|
||||
end, function(text)
|
||||
local items = {}
|
||||
if not text:find("^[^cC]") then table.insert(items, "Close Without Saving") end
|
||||
if not text:find("^[^sS]") then table.insert(items, "Save And Close") end
|
||||
return items
|
||||
end)
|
||||
})
|
||||
else
|
||||
do_close()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user