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

Jump back (i.e. ctrl-o) is broken after hop (at least :HopChar1) #44

Closed
idevat opened this issue Sep 18, 2023 · 1 comment · Fixed by #58
Closed

Jump back (i.e. ctrl-o) is broken after hop (at least :HopChar1) #44

idevat opened this issue Sep 18, 2023 · 1 comment · Fixed by #58

Comments

@idevat
Copy link

idevat commented Sep 18, 2023

Describe the bug
The cursor is on the position P. Use :HopChar1 to hop somwhere and the ctrl-o to jump back. Cursor is not on the original position P.

To Reproduce
Configuration:

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  { "smoka7/hop.nvim", opts = {} },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Steps to reproduce the behavior:

  1. Let's have a file with simple content:
first
second
third
  1. Put the cursor on the first line on character r.
  2. Run :HopChar1, use character i, so you get two targets (a in the word first and s in the word third) - choose s
  3. Press ctrl-o to jump back
  4. You are on character f in the word first

Expected behavior
After jump back by ctrl-o, you should be on the character r in the word first - the place before hop.

Version (please complete the following information):

  • Nvim version: 0.9.1
  • hop.nvim version: master

Additional context
Additionally - in the more complex content, the cursor is not even on the same line after ctrl-o.

Thank you for maintaining hop.nvim after the original project become unmaintained. However, after switch to this repo this issue appeared. It breaks e.g. following workflow: hop somewhere, cut/yank some content, jump back and put the content there.

@smoka7
Copy link
Owner

smoka7 commented Sep 18, 2023

Thanks for the report, it's a bug in upstream neovim/neovim#17861 .
The original code used vim.cmd("normal! m'") and when I changed it to new api I wasn't aware of ctrl-o and only tested it with ``.
Maybe we should revert it till that issue gets fixed.

@smoka7 smoka7 linked a pull request Nov 6, 2023 that will close this issue
@smoka7 smoka7 closed this as completed in #58 Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants