Skip to content

Commit

Permalink
Keep view at the code when running .smartest.* files
Browse files Browse the repository at this point in the history
Before this change, once you run the tests it will show "running X via Y
method". If you go to another Tmux window with your .smartest.* file, for
instance, once you return to Vim you're going to have to click yet another key.

Adding this code made the flow much snappier when the user is taken to
another terminal window. When they come back, they're right at the code
again.
  • Loading branch information
kurko committed Aug 23, 2020
1 parent 3a5cdfc commit ed28fb5
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions plugin/smartest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,27 @@ function! RunTests(filename)

" Replaces $smartest_test_command in the file with whatever smartest figured out as
" expected.
let final_test_command = substitute(test_command_from_file, "$smartest_test_command", smartest_test_command, "")
let final_test_command = substitute(final_test_command, "$filename", a:filename, "")
let final_test_command = substitute(test_command_from_file, "$smartest_test_command", smartest_test_command, "g")
let final_test_command = substitute(final_test_command, "$filename", a:filename, "g")

silent exec ":!echo " . smartest_test_description
" These lines were removed because when the user gets back to Vim, they
" would have to press a button to get back to code.
"
" Removing this code made the flow much snappier when the user is taken to
" another terminal window. When they come back, they're right at the code
" again.
"
" In case you want to see a message telling the user what's going on,
" uncomment these lines.
"
" silent exec ":!echo " . smartest_test_description
" shellescape will write with quotes to stdout
silent exec ":!echo Running: " . shellescape(final_test_command, 1)
exec ":!" . final_test_command
" silent exec "!echo Running: " . shellescape(final_test_command, 1)
" exec ":!" . final_test_command
"

silent exec "!" . final_test_command
redraw!
else
echo "Don't know how to run tests. Define .smartest." . smartest_test_context
endif
Expand Down

0 comments on commit ed28fb5

Please sign in to comment.