fix(prompt): allow cancelling title input

This commit is contained in:
Thomas Lambert
2022-09-29 11:11:20 +02:00
parent bc2c45ce6c
commit 76919abaaf
2 changed files with 24 additions and 2 deletions

21
lua/telekasten/utils.lua Normal file
View File

@@ -0,0 +1,21 @@
local M = {}
function M.prompt_title(callback)
local canceledStr = "__INPUT_CANCELLED__"
vim.ui.input({
prompt = "Title: ",
default = "",
cancelreturn = canceledStr,
}, function(title)
if title == canceledStr then
vim.cmd("echohl WarningMsg")
vim.cmd("echomsg 'Note creation cancelled!'")
vim.cmd("echohl None")
else
callback(title)
end
end)
end
return M