From 655dd3e2be99a7f0481dcee2e195d767a848545e Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Thu, 23 Apr 2015 00:27:56 +0200 Subject: [PATCH] Prevent stack trace of search errors. --- autoload/repeat.vim | 54 ++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/autoload/repeat.vim b/autoload/repeat.vim index 0884dc6..245a189 100644 --- a/autoload/repeat.vim +++ b/autoload/repeat.vim @@ -74,34 +74,38 @@ function! repeat#setreg(sequence,register) endfunction function! repeat#run(count) - if g:repeat_tick == b:changedtick - let r = '' - if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1]) - if g:repeat_reg[1] ==# '=' - " This causes a re-evaluation of the expression on repeat, which - " is what we want. - let r = '"=' . getreg('=', 1) . "\" + try + if g:repeat_tick == b:changedtick + let r = '' + if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1]) + if g:repeat_reg[1] ==# '=' + " This causes a re-evaluation of the expression on repeat, which + " is what we want. + let r = '"=' . getreg('=', 1) . "\" + else + let r = '"' . g:repeat_reg[1] + endif + endif + + let c = g:repeat_count + let s = g:repeat_sequence + let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) + if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) + exe 'norm ' . r . cnt . s else - let r = '"' . g:repeat_reg[1] + call feedkeys(s, 'i') + call feedkeys(r . cnt, 'ni') + endif + else + if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) + exe 'norm! '.(a:count ? a:count : '') . '.' + else + call feedkeys((a:count ? a:count : '') . '.', 'ni') endif endif - - let c = g:repeat_count - let s = g:repeat_sequence - let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) - if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) - exe 'norm ' . r . cnt . s - else - call feedkeys(s, 'i') - call feedkeys(r . cnt, 'ni') - endif - else - if ((v:version == 703 && has('patch100')) || (v:version == 704 && !has('patch601'))) - exe 'norm! '.(a:count ? a:count : '') . '.' - else - call feedkeys((a:count ? a:count : '') . '.', 'ni') - endif - endif + catch /^Vim\%((\a\+)\)\=:E\%(384\|385\|486\)/ + echohl ErrorMsg | echo substitute(v:exception, '^Vim\%((\a\+)\)\=:', '', '') | echohl None + endtry endfunction function! repeat#wrap(command,count)