From 767368d5e7965fb0a53df4845e16246d8eff73d9 Mon Sep 17 00:00:00 2001 From: Kien N Date: Tue, 4 Sep 2012 13:50:48 +0700 Subject: [PATCH] Also split if the buffer isn't writable --- autoload/ctrlp.vim | 12 +++++++----- autoload/ctrlp/quickfix.vim | 2 +- autoload/ctrlp/tag.vim | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index bb999dd..876595f 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1529,9 +1529,9 @@ fu! ctrlp#normcmd(cmd, ...) retu a:0 ? a:1 : 'bo vne' endf -fu! ctrlp#modfilecond() - retu &mod && !&hid && &bh != 'hide' && !&cf && !&awa - \ && s:bufwins(bufnr('%')) == 1 +fu! ctrlp#modfilecond(w) + retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf && + \ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 ) endf fu! s:nosplit() @@ -1787,8 +1787,10 @@ fu! s:buffunc(e) endf fu! s:openfile(cmd, fid, tail, chkmod, ...) - let cmd = a:chkmod && a:cmd =~ '^[eb]$' && ctrlp#modfilecond() - \ && !( a:cmd == 'b' && &aw ) ? ( a:cmd == 'b' ? 'sb' : 'sp' ) : a:cmd + let cmd = 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 j2l = a:0 && a:1[0] ? a:1[1] : 0 exe cmd.( a:0 && a:1[0] ? '' : a:tail ) ctrlp#fnesc(a:fid) diff --git a/autoload/ctrlp/quickfix.vim b/autoload/ctrlp/quickfix.vim index 8ac6e99..b42aace 100644 --- a/autoload/ctrlp/quickfix.vim +++ b/autoload/ctrlp/quickfix.vim @@ -47,7 +47,7 @@ fu! ctrlp#quickfix#accept(mode, str) cal ctrlp#exit() let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne' \ : 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) cal cursor(items[2], items[3]) sil! norm! zvzz diff --git a/autoload/ctrlp/tag.vim b/autoload/ctrlp/tag.vim index dda2505..83921a5 100644 --- a/autoload/ctrlp/tag.vim +++ b/autoload/ctrlp/tag.vim @@ -97,7 +97,7 @@ fu! ctrlp#tag#accept(mode, str) \ 'e': ['', 'tj'], \ } 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 let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd if fnd[0] == 1