Skip to content

Commit

Permalink
coverage: allow to run coverage on _test.go files in subdirs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pborzenkov committed Nov 23, 2016
1 parent c63c798 commit 2b34076
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autoload/go/coverage.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 2b34076

Please sign in to comment.