diff --git a/autoload/repeat.vim b/autoload/repeat.vim index bc31a77..f2caeb4 100644 --- a/autoload/repeat.vim +++ b/autoload/repeat.vim @@ -74,34 +74,39 @@ 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(normal):/ + return 'echoerr v:errmsg' + endtry + return '' endfunction function! repeat#wrap(command,count) @@ -112,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)