diff options
Diffstat (limited to 'autoload/rust.vim')
-rw-r--r-- | autoload/rust.vim | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/autoload/rust.vim b/autoload/rust.vim index 8bb2b126..373be590 100644 --- a/autoload/rust.vim +++ b/autoload/rust.vim @@ -501,7 +501,15 @@ function! s:SearchTestFunctionNameUnderCursor() abort " Search the end of test function (closing brace) to ensure that the " cursor position is within function definition - normal! % + if maparg('<Plug>(MatchitNormalForward)') ==# '' + normal! % + else + " Prefer matchit.vim official plugin to native % since the plugin + " provides better behavior than original % (#391) + " To load the plugin, run: + " :packadd matchit + execute 'normal' "\<Plug>(MatchitNormalForward)" + endif if line('.') < cursor_line return '' endif @@ -543,21 +551,20 @@ function! rust#Test(mods, winsize, all, options) abort let saved = getpos('.') try let func_name = s:SearchTestFunctionNameUnderCursor() - if func_name ==# '' - echohl ErrorMsg - echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' - echohl None - return - endif - if a:options ==# '' - execute cmd . 'cargo test --manifest-path' manifest func_name - else - execute cmd . 'cargo test --manifest-path' manifest func_name a:options - endif - return finally call setpos('.', saved) endtry + if func_name ==# '' + echohl ErrorMsg + echomsg 'No test function was found under the cursor. Please add ! to command if you want to run all tests' + echohl None + return + endif + if a:options ==# '' + execute cmd . 'cargo test --manifest-path' manifest func_name + else + execute cmd . 'cargo test --manifest-path' manifest func_name a:options + endif endfunction " }}}1 |