BufWrite autocmd runs code from old saved version of file
Stratus3D opened this issue · comments
In my .vimrc
I have the following:
augroup test
autocmd!
" Run tests automatically when a file is saved
autocmd BufWrite * if test#exists() |
\ TestFile |
\ endif
augroup END
Taken from the autocommands section of the readme - https://github.com/vim-test/vim-test#autocommands
With this code in place, vim-test runs the tests when I type :w
in Vim's command line vim-tests runs the tests contained in the file, but the tests run are from a previously saved version of the file. The new changes that are being saved are not used in the test run.
Checking the issue tracker I do not see anyone else reporting this issue, but I've experienced it for some time. It occurs with Erlang, Elixir and Rust on my Ubuntu machine. Interestingly it does not occur on OSX. It's possible something else in my vimrc that is interfering with this plugin. Here is a link to my vimrc if anyone wants to take a look at it: https://github.com/Stratus3D/dotfiles/blob/master/vimrc#L502-L509
BufWrite commands are called before the buffer is written to the file. Have you tried a BufWritePost command as they are called after the file has been written?
@andrew-cybsafe it'd been a while since I investigated this issue, but I went back and updated my config so TestFile
was called on BufWritePost
and now everything is working! Not sure what I did wrong before, but it appears vim-test is working as expected. Thanks for your help!