Merge pull request #64 from Ind1eMonk3y/master

Enhance cursor offset saving/restoring
This commit is contained in:
ThePrimeagen 2021-04-27 12:14:13 -06:00 committed by GitHub
commit c2500292d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -62,10 +62,11 @@ local function get_buf_name(id)
end end
local function create_mark(filename) local function create_mark(filename)
local cursor_pos = vim.fn.getcurpos()
return { return {
filename = filename, filename = filename,
row = 0, row = cursor_pos[2],
col = 0, col = cursor_pos[3],
} }
end end
@ -179,8 +180,9 @@ M.store_offset = function()
return return
end end
harpoon.get_mark_config().marks[idx].row = local cursor_pos = vim.fn.getcurpos()
vim.fn.line("."); harpoon.get_mark_config().marks[idx].row = cursor_pos[2]
harpoon.get_mark_config().marks[idx].col = cursor_pos[3]
end) end)
if not ok then if not ok then

View File

@ -106,7 +106,7 @@ M.nav_file = function(id)
vim.api.nvim_set_current_buf(buf_id) vim.api.nvim_set_current_buf(buf_id)
if set_row and mark.row then if set_row and mark.row then
vim.cmd(string.format(":%d", mark.row)) vim.cmd(string.format(":call cursor(%d, %d)", mark.row, mark.col))
end end
end end