Skip to content

Commit

Permalink
Also split if the buffer isn't writable
Browse files Browse the repository at this point in the history
  • Loading branch information
kien committed Sep 6, 2012
1 parent 1fd3760 commit 767368d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions autoload/ctrlp.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion autoload/ctrlp/quickfix.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion autoload/ctrlp/tag.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 767368d

Please sign in to comment.