From ede4d66bdf6d48d318c9d3b16973530b1c2c292f Mon Sep 17 00:00:00 2001 From: phanium Date: Mon, 20 May 2024 00:05:55 +0800 Subject: [PATCH] fix: always save last position before jump --- lua/various-textobjs/blockwise-textobjs.lua | 3 +++ lua/various-textobjs/charwise-textobjs.lua | 2 ++ lua/various-textobjs/linewise-textobjs.lua | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lua/various-textobjs/blockwise-textobjs.lua b/lua/various-textobjs/blockwise-textobjs.lua index dfba407..760ebdc 100644 --- a/lua/various-textobjs/blockwise-textobjs.lua +++ b/lua/various-textobjs/blockwise-textobjs.lua @@ -24,6 +24,9 @@ function M.column() until hitsIndent or shorterLine local linesDown = nextLnum - 1 - startRow + -- save last position in jumplist + u.normal("m`") + -- start visual block mode -- INFO requires special character `^V` if not (fn.mode() == "") then vim.cmd.execute([["normal! \"]]) end diff --git a/lua/various-textobjs/charwise-textobjs.lua b/lua/various-textobjs/charwise-textobjs.lua index a784d3c..3f6e476 100644 --- a/lua/various-textobjs/charwise-textobjs.lua +++ b/lua/various-textobjs/charwise-textobjs.lua @@ -18,6 +18,8 @@ end ---@param startPos pos ---@param endPos pos function M.setSelection(startPos, endPos) + -- save last position in jumplist + u.normal("m`") vim.api.nvim_win_set_cursor(0, startPos) if isVisualMode() then u.normal("o") diff --git a/lua/various-textobjs/linewise-textobjs.lua b/lua/various-textobjs/linewise-textobjs.lua index 8b0e9b5..9d383c9 100644 --- a/lua/various-textobjs/linewise-textobjs.lua +++ b/lua/various-textobjs/linewise-textobjs.lua @@ -18,6 +18,8 @@ end ---@param startline integer ---@param endline integer local function setLinewiseSelection(startline, endline) + -- save last position in jumplist (see #86) + u.normal("m`") a.nvim_win_set_cursor(0, { startline, 0 }) if not isVisualLineMode() then u.normal("V") end u.normal("o")