From 2b34076d0395497dc9db8705f4f98269287024cf Mon Sep 17 00:00:00 2001 From: Pavel Borzenkov Date: Fri, 2 Sep 2016 17:37:42 +0300 Subject: [PATCH] coverage: allow to run coverage on _test.go files in subdirs Due to usage of ':t' modifier to extract filename when switching from file_test.go to file.go, the original path to file is lost and Vim can't open it if it's stored in some subdir. It only worked by accident if the file was located in the same directory. --- autoload/go/coverage.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/go/coverage.vim b/autoload/go/coverage.vim index f3d36c4314..afdaffc6e7 100644 --- a/autoload/go/coverage.vim +++ b/autoload/go/coverage.vim @@ -204,7 +204,7 @@ function! go#coverage#overlay(file) let cnt += 1 endwhile - let fname = expand('%:t') + let fname = expand('%') " when called for a _test.go file, run the coverage for the actuall file " file @@ -221,6 +221,9 @@ function! go#coverage#overlay(file) exe ":edit ". fnamemodify(fname, ":p") endif + " cov.file includes only the filename itself, without full path + let fname = fnamemodify(fname, ":t") + for line in lines[1:] let cov = go#coverage#parsegocoverline(line)