Skip to content
This repository
Browse code

Also split if the buffer isn't writable

  • Loading branch information...
commit 767368d5e7965fb0a53df4845e16246d8eff73d9 1 parent 1fd3760
authored September 04, 2012
12  autoload/ctrlp.vim
@@ -1529,9 +1529,9 @@ fu! ctrlp#normcmd(cmd, ...)
1529 1529
 	retu a:0 ? a:1 : 'bo vne'
1530 1530
 endf
1531 1531
 
1532  
-fu! ctrlp#modfilecond()
1533  
-	retu &mod && !&hid && &bh != 'hide' && !&cf && !&awa
1534  
-		\ && s:bufwins(bufnr('%')) == 1
  1532
+fu! ctrlp#modfilecond(w)
  1533
+	retu &mod && !&hid && &bh != 'hide' && s:bufwins(bufnr('%')) == 1 && !&cf &&
  1534
+		\ ( ( !&awa && a:w ) || filewritable(fnamemodify(bufname('%'), ':p')) != 1 )
1535 1535
 endf
1536 1536
 
1537 1537
 fu! s:nosplit()
@@ -1787,8 +1787,10 @@ fu! s:buffunc(e)
1787 1787
 endf
1788 1788
 
1789 1789
 fu! s:openfile(cmd, fid, tail, chkmod, ...)
1790  
-	let cmd = a:chkmod && a:cmd =~ '^[eb]$' && ctrlp#modfilecond()
1791  
-		\ && !( a:cmd == 'b' && &aw ) ? ( a:cmd == 'b' ? 'sb' : 'sp' ) : a:cmd
  1790
+	let cmd = a:cmd
  1791
+	if a:chkmod && cmd =~ '^[eb]$' && ctrlp#modfilecond(!( cmd == 'b' && &aw ))
  1792
+		let cmd = cmd == 'b' ? 'sb' : 'sp'
  1793
+	en
1792 1794
 	let cmd = cmd =~ '^tab' ? ctrlp#tabcount().cmd : cmd
1793 1795
 	let j2l = a:0 && a:1[0] ? a:1[1] : 0
1794 1796
 	exe cmd.( a:0 && a:1[0] ? '' : a:tail ) ctrlp#fnesc(a:fid)
2  autoload/ctrlp/quickfix.vim
@@ -47,7 +47,7 @@ fu! ctrlp#quickfix#accept(mode, str)
47 47
 	cal ctrlp#exit()
48 48
 	let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
49 49
 		\ : ctrlp#normcmd('e')
50  
-	let cmd = cmd == 'e' && ctrlp#modfilecond() ? 'new' : cmd
  50
+	let cmd = cmd == 'e' && ctrlp#modfilecond(1) ? 'new' : cmd
51 51
 	exe cmd ctrlp#fnesc(filpath)
52 52
 	cal cursor(items[2], items[3])
53 53
 	sil! norm! zvzz
2  autoload/ctrlp/tag.vim
@@ -97,7 +97,7 @@ fu! ctrlp#tag#accept(mode, str)
97 97
 		\ 'e': ['', 'tj'],
98 98
 		\ }
99 99
 	let cmd = fnd[0] == 1 ? cmds[a:mode][0] : cmds[a:mode][1]
100  
-	let cmd = a:mode == 'e' && ctrlp#modfilecond() && !&aw
  100
+	let cmd = a:mode == 'e' && ctrlp#modfilecond(!&aw)
101 101
 		\ ? ( cmd == 'tj' ? 'stj' : 'sp' ) : cmd
102 102
 	let cmd = a:mode == 't' ? ctrlp#tabcount().cmd : cmd
103 103
 	if fnd[0] == 1

0 notes on commit 767368d

Please sign in to comment.
Something went wrong with that request. Please try again.