Skip to content

Commit

Permalink
fix: repair refile to headline in the same file
Browse files Browse the repository at this point in the history
- use correct line position from target headline
- reset cursor back
  • Loading branch information
seflue committed Dec 27, 2023
1 parent 92bfc3f commit 8b00b8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/orgmode/capture/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ function Capture:_refile_to(opts)

local item = opts.item
if is_same_file and item then
vim.cmd(string.format('silent! %d,%d move %s', item.range.start_line, item.range.end_line, tostring(opts.file)))
local target = opts.range.end_line
local pos = vim.fn.getcurpos()
vim.cmd(string.format('silent! %d,%d move %s', item.range.start_line, item.range.end_line, target))
vim.fn.cursor(pos[2], pos[3])
return true
end

Expand Down

0 comments on commit 8b00b8b

Please sign in to comment.