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

ctrl+o broken after :GoDef #1026

Closed
dmac opened this issue Aug 25, 2016 · 8 comments
Closed

ctrl+o broken after :GoDef #1026

dmac opened this issue Aug 25, 2016 · 8 comments

Comments

@dmac
Copy link

dmac commented Aug 25, 2016

Actual behavior

After using :GoDef (or gd from normal mode) to jump to a definition, using ctrl+o to jump back to the previous location will often not work, sending you to the wrong location.

Expected behavior

Using ctrl+o after gd should send you back to the previous location. It should be possible to gd then ctrl+o repeatedly to move back and forth between a usage and definition.

Steps to reproduce:

foo.go:

package main

func main() {
    foo()
}

func foo() {}

Repro:

  1. Move to the foo() call in main.
  2. Press gd and ctrl+o repeatedly to try to move back and forth between the usage and definition of foo.

I bisected and found 445e5bf to be the first commit where this repros for me.

Configuration

  • .vimrc:
set nocompatible
filetype off

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'

call vundle#end()
filetype plugin indent on
syntax on
  • vim version:
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 14 2016 16:06:49)
Compiled by root@apple.com
Normal version without GUI.  Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer -profile +python/dyn
-python3 +quickfix +reltime -rightleft +ruby/dyn +scrollbind +signs
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
 -xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses
  • vim-go version: 445e5bf..master
  • go version: go version go1.7 darwin/amd64
@nhooyr
Copy link
Contributor

nhooyr commented Aug 25, 2016

Use <C-T> for this.

@dmac
Copy link
Author

dmac commented Aug 25, 2016

I understand the difference between the jump list and the tag stack, but in my experience most environments treat jumping to a tag definition as a location change, such that either ctrl-t or ctrl-o would jump backwards to the same previous location. The bisected commit message doesn't mention changing this behavior, which made me suspect it was unintentional.

@fatih
Copy link
Owner

fatih commented Aug 26, 2016

Hi @dmac

As @nhooyr said you should use c-t not c-o. I don't want to override c-o as it's a fairly used mapping in Vim. For your case, actually c-o jumps correctly, because the initial cursor was at the top of your file, so if you hit c-o you'll jump back. Whereas <c-t> will jump to the definition. Thanks for opening it.

@fatih fatih closed this as completed Aug 26, 2016
@nhooyr
Copy link
Contributor

nhooyr commented Aug 26, 2016

@fatih I think what @dmac wants is for the jump to the definition to be on the jump list as well as the tag stack.

We just have to change the cursor() calls to execute "normal ".line."G".col."|"

@dmac
Copy link
Author

dmac commented Aug 26, 2016

Yes, exactly. I'm actually not aware of any language plugin which implements a "go to definition" command that doesn't also add that movement to the jump list (though I'd be happy to see counterexamples). Also worth noting is that the default behavior of gd with no plugins (go to local definition) does work with<c-o>, but that's no longer the case in vim-go.

@fatih
Copy link
Owner

fatih commented Aug 27, 2016

Hey @dmac, sorry for early closing. I see that there is indeed an issue. I'll check @nhooyr fix now and going to merge it.

@fatih fatih reopened this Aug 27, 2016
@fatih fatih closed this as completed Aug 27, 2016
@fatih
Copy link
Owner

fatih commented Aug 27, 2016

Fixed with #1029

@dmac
Copy link
Author

dmac commented Aug 27, 2016

Awesome, thanks for the quick fix!

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