Feat: save popup contents to register (#163)

Users can now provide a backup register when creating comments, notes, and so forth which will automatically be populated with the contents of the buffer prior to submission to Gitlab. This ensures that even if the API call fails the contents of the buffer is saved, which prevents the user from losing their changes. This is a MINOR update.
This commit is contained in:
Jakub F. Bortlík
2024-01-22 14:14:40 +01:00
committed by GitHub
parent b6f023373a
commit 132dd60b95
3 changed files with 23 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ M.settings = {
help = nil,
pipeline = nil,
squash_message = nil,
backup_register = nil,
},
discussion_tree = {
auto_open = true,
@@ -273,6 +274,9 @@ M.set_popup_keymaps = function(popup, action, linewise_action, opts)
if action ~= nil then
vim.keymap.set("n", M.settings.popup.perform_action, function()
local text = u.get_buffer_text(popup.bufnr)
if M.settings.popup.backup_register ~= nil then
vim.cmd("0,$yank " .. M.settings.popup.backup_register)
end
if opts.action_before_close then
action(text, popup.bufnr)
exit(popup, opts)