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

Last cursor position lost #88

Open
jeebak opened this issue May 17, 2021 · 3 comments
Open

Last cursor position lost #88

jeebak opened this issue May 17, 2021 · 3 comments

Comments

@jeebak
Copy link

jeebak commented May 17, 2021

HI there,

I just installed this plugin and am enjoying it so far, but I'm running into unexpected behavior. After invoking AnyJump it seems the cursor is moved to the top of the buffer before the popup is opened, and worse the cursor is left near the top of the buffer when the popup's closed (via esc/q.) I'd've expected the cursor to be placed back at the original position before AnyJump was invoked. I looked at the README and the help. Is there a setting or caveat that I've overlooked?

Thanks!

@matthewmoto
Copy link

I just wanted to leave a note that I'm experiencing this as well running Vim 8.2 under Cygwin (yuck, I know), in case there was any questions of NeoVim vs Vim or versioning. I'm available as a guinea pig for testing fixes as well.

It's a frequent use case that I'll hit esc after realizing that the term I have under the cursor is not the one I want to search (huge code-base).

@jeebak
Copy link
Author

jeebak commented Jun 2, 2021

The workaround I'm using is wrapping the call using bling's Preserve function, thusly:

  function! Preserve(command)
    " preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " do the business:
    execute a:command
    " clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
  endfunction

  Plug 'pechorin/any-jump.vim' "{{{
    " Jump to any definition and references 👁 IDE madness without overhead 🚀

    let g:any_jump_disable_default_keybindings = 1
    let g:any_jump_list_numbers = 1

    nnoremap <leader>j :call Preserve("AnyJump")<CR>
    xnoremap  <leader>j :call Preserve("AnyJump")<CR>
  "}}}

@alexbarton
Copy link

I'm seeing this as well, VIM 9.0 on Linux.

And thanks a lot, @jeebak, your workaround works great for me, too!

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

No branches or pull requests

3 participants