-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
GoDef that takes you to a file that's already open in another Vim doesn't work correctly #2504
Comments
I believe the root of the problem is in autoload/go/def.vim, in function! go#def#jump_to_declaration(out, mode, bin_name) abort
" ...
exec cmd fnameescape(fnamemodify(filename, ':.')) Since there's an exception when opening the file, the rest of the function after that (and in the rest of the call stack) isn't executed. I added these lines around that let local_shm = &shm
set shm+=A
try
exec cmd fnameescape(fnamemodify(filename, ':.'))
finally
exec "set shm=" . local_shm
endtry This saves And that seems to work. Or at least it successfully masks the error! |
Thank you for the bug report. You're right that your solution masks the error. I'd like to find a way to show the message about the the swap file without also exiting the function prematurely, but so far my attempts have always result in being placed in an empty buffer (except for when choosing the Recover option) 🤔 |
I've submitted a pull request, #2518, that mostly resolves this, but unless you choose the recover option when presented with the option of what to do about the swap file, for some reason the buffer it initially displays is sometimes empty. You can execute |
What did you do?
^]
(aka:GoDef
) on a Go typeThe file that holds the type is being edited by another Vim. So, for example, a swapfile for that file exists.
What did you expect to happen?
Open the other file, with the cursor on the type.
What happened instead?
Error / exception:
Found a swap file by the name ... [etc]
and these messages:
(I believe the above is due to Vim throwing an exception while reading the new file. I don't think the
:endif
is actually missing.)The new file opens with the cursor at the top of the file.
Configuration:
vim-go version:
Tip as of 9/20/2019.
vimrc
you used to reproduce:vimrc
That's it, the whole thing. I commented everything else out and was still able to reproduce this bug.
Vim version (first three lines from
:version
):VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 21 2019 22:54:00)
macOS version
Included patches: 1-1722
Compiled by Homebrew
Huge version with MacVim GUI.
Go version (
go version
):go version go1.13 darwin/amd64
Go environment
go env
Output:The text was updated successfully, but these errors were encountered: