Skip to content

Commit a97eb7f

Browse files
mhinzda-x
authored andcommitted
RustTest: support optional window sizes
Examples: :10RustTest :vert 80RustTest
1 parent fb3fa6e commit a97eb7f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

autoload/rust.vim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,20 +507,23 @@ function! s:SearchTestFunctionNameUnderCursor() abort
507507
return matchstr(getline(test_func_line), '\m\C^\s*fn\s\+\zs\h\w*')
508508
endfunction
509509

510-
function! rust#Test(mods, all, options) abort
510+
function! rust#Test(mods, winsize, all, options) abort
511511
let manifest = findfile('Cargo.toml', expand('%:p:h') . ';')
512512
if manifest ==# ''
513513
return rust#Run(1, '--test ' . a:options)
514514
endif
515515

516+
" <count> defaults to 0, but we prefer an empty string
517+
let winsize = a:winsize ? a:winsize : ''
518+
516519
if has('terminal')
517520
if has('patch-8.0.910')
518-
let cmd = printf('%s noautocmd new | terminal ++curwin ', a:mods)
521+
let cmd = printf('%s noautocmd %snew | terminal ++curwin ', a:mods, winsize)
519522
else
520523
let cmd = printf('%s terminal ', a:mods)
521524
endif
522525
elseif has('nvim')
523-
let cmd = printf('%s noautocmd new | terminal ', a:mods)
526+
let cmd = printf('%s noautocmd %snew | terminal ', a:mods, winsize)
524527
else
525528
let cmd = '!'
526529
let manifest = shellescape(manifest)

ftplugin/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ command! -bar RustInfoToClipboard call rust#debugging#InfoToClipboard()
136136
command! -bar -nargs=1 RustInfoToFile call rust#debugging#InfoToFile(<f-args>)
137137

138138
" See |:RustTest| for docs
139-
command! -buffer -nargs=* -bang RustTest call rust#Test(<q-mods>, <bang>0, <q-args>)
139+
command! -buffer -nargs=* -count -bang RustTest call rust#Test(<q-mods>, <count>, <bang>0, <q-args>)
140140

141141
if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args")
142142
let b:rust_last_rustc_args = []

0 commit comments

Comments
 (0)