From 655dd3e2be99a7f0481dcee2e195d767a848545e Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Thu, 23 Apr 2015 00:27:56 +0200 Subject: [PATCH 1/2] 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) From e42a430e644f68a8d7da32425158600fb48ab8cd Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Thu, 23 Apr 2015 01:45:15 +0200 Subject: [PATCH 2/2] More realistic Vim error, and catch all normal exceptions. --- autoload/repeat.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autoload/repeat.vim b/autoload/repeat.vim index 245a189..8fd9df5 100644 --- a/autoload/repeat.vim +++ b/autoload/repeat.vim @@ -103,9 +103,10 @@ function! repeat#run(count) 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 + catch /^Vim(normal):/ + return 'echoerr v:errmsg' endtry + return '' endfunction function! repeat#wrap(command,count) @@ -116,7 +117,7 @@ function! repeat#wrap(command,count) endif endfunction -nnoremap (RepeatDot) :call repeat#run(v:count) +nnoremap (RepeatDot) :exe repeat#run(v:count) nnoremap (RepeatUndo) :call repeat#wrap('u',v:count) nnoremap (RepeatUndoLine) :call repeat#wrap('U',v:count) nnoremap (RepeatRedo) :call repeat#wrap("\C-R>",v:count)