diff --git a/lua/harpoon/mark.lua b/lua/harpoon/mark.lua index 39fb9c6..f0dfafa 100644 --- a/lua/harpoon/mark.lua +++ b/lua/harpoon/mark.lua @@ -67,10 +67,11 @@ local function get_buf_name(id) end local function create_mark(filename) + local cursor_pos = vim.fn.getcurpos() return { filename = filename, - row = 0, - col = 0, + row = cursor_pos[2], + col = cursor_pos[3], } end @@ -196,9 +197,10 @@ M.store_offset = function() return end - local line = vim.fn.line(".") - harpoon.get_mark_config().marks[idx].row = line - log.debug("store_offset(): Stored line:", line) + local cursor_pos = vim.fn.getcurpos() + log.debug(string.format("store_offset(): Stored row: %d, col: %d", cursor_pos[2], cursor_pos[3])) + harpoon.get_mark_config().marks[idx].row = cursor_pos[2] + harpoon.get_mark_config().marks[idx].col = cursor_pos[3] end) if not ok then diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 92d3936..738d1b0 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -108,9 +108,12 @@ M.nav_file = function(id) vim.api.nvim_set_current_buf(buf_id) if set_row and mark.row then - local ok, err = pcall(vim.cmd, string.format(":%d", mark.row)) + local ok, err = pcall(vim.cmd, string.format(":call cursor(%d, %d)", mark.row, mark.col)) if not ok then - log.warn("nav_file(): Could not set row to", mark.row, err) + log.warn( + string.format("nav_file(): Could not set cursor to row: %d, col: %d", mark.row, mark.col), + err + ) end end end