Closed lyokha closed 12 years ago
Additional comments: it is better to change 1st chunk to:
if bufnr('') ==1 call feedkeys(":wincmd l\n", 't') endif call feedkeys(":0\n", 't')
Also i found 2 new issues when one or more buffers are already open in current vim instance:
Here is final patch:
--- autoload/recover.vim 2012-04-02 17:09:12.698403668 +0400
+++ autoload/recover.vim.new 2012-04-02 16:52:45.761707457 +0400
@@ -70,7 +70,13 @@
call recover#DiffRecoveredFile()
" Not sure, why this needs feedkeys
" Sometimes cursor is wrong, I hate when this happens
- call feedkeys(":wincmd p\n:0\n", 't')
+ " Cursor is wrong only when there is a single buffer open, a simple
+ " workaround for that is to check if bufnr('') is 1: in this case
+ " ':wincmd l\n:0\n' must be fed
+ if bufnr('') == 1
+ call feedkeys(":wincmd l\n", 't')
+ endif
+ call feedkeys(":0\n", 't')
endif
let b:did_recovery = 1
endif
@@ -104,7 +110,10 @@
let b:mod='recovered version'
let l:filetype = &ft
" saved version
+ let curspr = &spr
+ set nospr
noa vert new
+ let &l:spr = curspr
0r #
$d _
if l:filetype != ""
@@ -116,7 +125,7 @@
setl noswapfile buftype=nowrite bufhidden=delete nobuflisted
let b:mod='unmodified version on-disk'
let swapbufnr=bufnr('')
- noa wincmd p
+ noa wincmd l
let b:swapbufnr = swapbufnr
command! -buffer RecoverPluginFinish :FinishRecovery
command! -buffer FinishRecovery :call recover#RecoverFinish()
@@ -182,13 +191,16 @@
endfun
fu! recover#RecoverFinish() abort "{{{1
+ let swapname = b:swapname
+ let curbufnr = bufnr('')
+ delcommand FinishRecovery
exe bufwinnr(b:swapbufnr) " wincmd w"
diffoff
bd!
- call delete(b:swapname)
- delcommand FinishRecovery
+ call delete(swapname)
diffoff
call s:ModifySTL(0)
+ exe bufwinnr(curbufnr) " wincmd w"
unlet! b:swapname b:did_recovery b:swapbufnr
endfun
Regards, Alexey.
Thanks for your feedback . I'll include it.
Hi Christian.
I found 2 new issues and 1 workaround for feedkeys() in CheckRecover(). Here is a patch (i do not know how attach file here), i followed your indentation rules: