Skip to content

Commit

Permalink
Fix handling capture window close.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristijanhusak committed Jun 29, 2021
1 parent b8c027b commit 93b2df8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lua/orgmode/capture/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ function Capture:refile(confirm)
local is_modified = vim.bo.modified
local template = vim.api.nvim_buf_get_var(0, 'org_template') or {}
local file = vim.fn.fnamemodify(template.target or config.org_default_notes_file, ':p')
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
if confirm and is_modified then
local choice = vim.fn.confirm(string.format('Do you want to refile this to %s?', file), '&Yes\n&No')
vim.cmd[[redraw!]]
if choice ~= 1 then
return utils.echo_info('Canceled.')
end
end
-- TODO: Parse refile content as org file and update refile destination to point to headline or root
self:_refile_to_end(file, vim.api.nvim_buf_get_lines(0, 0, -1, true))
vim.defer_fn(function()
-- TODO: Parse refile content as org file and update refile destination to point to headline or root
self:_refile_to_end(file, lines)
end, 0)
vim.cmd[[autocmd! OrgCapture BufWipeout <buffer>]]
vim.cmd[[silent! wq]]
end
Expand Down Expand Up @@ -219,6 +222,7 @@ function _G.orgmode.autocomplete_refile(arg_lead)
end

function Capture:kill()
vim.cmd[[autocmd! OrgCapture BufWipeout <buffer>]]
vim.cmd[[bw!]]
end

Expand Down

0 comments on commit 93b2df8

Please sign in to comment.