Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always save last position before jump #86

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/various-textobjs/blockwise-textobjs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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! \<C-v>"]]) end
Expand Down
2 changes: 2 additions & 0 deletions lua/various-textobjs/charwise-textobjs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions lua/various-textobjs/linewise-textobjs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading