Also split if the buffer isn't writable

This commit is contained in:
Kien N 2012-09-04 13:50:48 +07:00
parent 1fd3760b94
commit 767368d5e7
3 changed files with 9 additions and 7 deletions

View File

@ -1529,9 +1529,9 @@ fu! ctrlp#normcmd(cmd, ...)
retu a:0 ? a:1 : 'bo vne' retu a:0 ? a:1 : 'bo vne'
endf endf
fu! ctrlp#modfilecond() fu! ctrlp#modfilecond(w)
retu &mod && !&hid && &bh != 'hide' && !&cf && !&awa retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf &&
\ && s:bufwins(bufnr('%')) == 1 \ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 )
endf endf
fu! s:nosplit() fu! s:nosplit()
@ -1787,8 +1787,10 @@ fu! s:buffunc(e)
endf endf
fu! s:openfile(cmd, fid, tail, chkmod, ...) fu! s:openfile(cmd, fid, tail, chkmod, ...)
let cmd = a:chkmod && a:cmd =~ '^[eb]$' && ctrlp#modfilecond() let cmd = a:cmd
\ && !( a:cmd == 'b' && &aw ) ? ( a:cmd == 'b' ? 'sb' : 'sp' ) : a:cmd if a:chkmod && cmd =~ '^[eb]$' && ctrlp#modfilecond(!( cmd == 'b' && &aw ))
let cmd = cmd == 'b' ? 'sb' : 'sp'
en
let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd
let j2l = a:0 && a:1[0] ? a:1[1] : 0 let j2l = a:0 && a:1[0] ? a:1[1] : 0
exe cmd.( a:0 && a:1[0] ? '' : a:tail ) ctrlp#fnesc(a:fid) exe cmd.( a:0 && a:1[0] ? '' : a:tail ) ctrlp#fnesc(a:fid)

View File

@ -47,7 +47,7 @@ fu! ctrlp#quickfix#accept(mode, str)
cal ctrlp#exit() cal ctrlp#exit()
let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne' let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
\ : ctrlp#normcmd('e') \ : ctrlp#normcmd('e')
let cmd = cmd == 'e' && ctrlp#modfilecond() ? 'new' : cmd let cmd = cmd == 'e' && ctrlp#modfilecond(1) ? 'new' : cmd
exe cmd ctrlp#fnesc(filpath) exe cmd ctrlp#fnesc(filpath)
cal cursor(items[2], items[3]) cal cursor(items[2], items[3])
sil! norm! zvzz sil! norm! zvzz

View File

@ -97,7 +97,7 @@ fu! ctrlp#tag#accept(mode, str)
\ 'e': ['', 'tj'], \ 'e': ['', 'tj'],
\ } \ }
let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1] let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
let cmd = a:mode == 'e' && ctrlp#modfilecond() && !&aw let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd \ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
if fnd[0] == 1 if fnd[0] == 1