pechorin/any-jump.vim

Last cursor position lost

jeebak opened this issue ยท 3 comments

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!

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).

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>
  "}}}

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

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