fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
16.01k stars 1.45k forks source link

Term JumpTo Causes Empty Buffer #2806

Closed ldelossa closed 4 years ago

ldelossa commented 4 years ago

What did you do? (required: The issue will be closed when not provided)

Ran a terminal driven command such as GoTest.

What did you expect to happen?

The test to fail and jump to a file where the issue exists

What happened instead?

When the file which causes an error is in another library or the stdlib, the path to the source file cannot be determined and an empty buffer is created

Removing ths line fixes the issue: https://github.com/fatih/vim-go/blob/d2e82b50a822ee2dcfb51aef266d28ce433d4bc9/autoload/go/term.vim#L201

I am not sure however if this is the "right" thing to do. Ideally you could jump to the location in a imported package's file and see where the error existed that failed the test.

You can reproduce this issue by importing a package, alterting that package to produce a test failure case, and running GoTest in terminal mode (vim8 or nvim, shouldn't matter)

Configuration (MUST fill this out):

vim-go version:

vimrc you used to reproduce:

vimrc

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 18 2020 14:57:56) Included patches: 1-401 Compiled by louis@localhost.localdomain

Go version (go version):

go version go1.14 linux/amd64

Go environment

go env Output:

GO111MODULE=""
GOARCH="amd64"
GOBIN="/home/louis/git/gopath/bin"
GOCACHE="/home/louis/.cache/go-build"
GOENV="/home/louis/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/louis/git/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="/usr/bin/clang"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/louis/git/go/clair-notifier-wt/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build758226058=/tmp/go-build -gno-record-gcc-switches"

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.3.4
    golang.org/x/tools/gopls@v0.3.4 h1:4GC7q/pXQ/tsxHBGVdsMdlB4gCxVC06m/7rIXg1Px4E=

vim-go configuration:

vim-go configuration
g:go_list_type = 'quickfix'
g:go_highlight_operators = 1
g:go_jump_to_error = 1
g:go_term_enabled = 1
g:go_metalinter_deadline = '5s'
g:go_highlight_fields = 1
g:go_rename_command = 'gopls'
g:go_doc_popup_window = 1
g:go_highlight_structs = 1
g:go_disable_autoinstall = 0
g:go_highlight_functions = 1
g:go_gotags_bin = 'gotags'
g:go_test_show_name = 1
g:go_test_timeout = '600s'
g:go_highlight_types = 1
g:go_fmt_command = 'goimports'
g:go_highlight_methods = 1
g:go_list_height = 10
g:go_term_exit = 1
g:go_fmt_experimental = 1
g:go_loaded_gosnippets = 1
g:go_term_height = 10
g:go_term_mode = 'split'
g:go_build_tags = 'integration'
g:go_highlight_build_constraints = 1
g:go_loaded_install = 1
g:go_decls_mode = 'fzf'

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bhcleek commented 4 years ago

I suspect the right thing to do here is to move https://github.com/fatih/vim-go/blob/d2e82b50a822ee2dcfb51aef266d28ce433d4bc9/autoload/go/term.vim#L204 above https://github.com/fatih/vim-go/blob/d2e82b50a822ee2dcfb51aef266d28ce433d4bc9/autoload/go/term.vim#L201

edit: update links to permalinks (master has changed since the original draft)

ldelossa commented 4 years ago

will test.

bhcleek commented 4 years ago

@ldelossa did you have a chance to try out my suggestion?

bhcleek commented 4 years ago

@ldelossa I've tried to duplicate what you've described without success.

Here's a script that I created to try to duplicate:

#!/bin/sh

mkdir 2806
cd 2806

go mod init github.com/bhcleek/2806

cat <<EOF > main_test.go
package main

import (
    "github.com/bhcleek/2806/subdir"
    "testing"
)

func TestHelloWorld(t *testing.T) {
    subdir.Foo()
    t.Fatal("not implemented")
}
EOF

mkdir subdir

cat <<EOF > subdir/subdir.go
package subdir 

import "fmt"

func Foo() {
    fmt.Println("vim-go"
}
EOF

vim -c 'let g:go_term_enabled=1' -c :GoTest main_test.go
ldelossa commented 4 years ago

@bhcleek sorry was a bit MIA for a little. I can't seem to reproduce this. So I am going to close.