Commits

kien committed 2a04d78 Draft

Further reduce MRU saving

Only save once when a new entry is added.

Comments (0)

Files changed (2)

autoload/ctrlp.vim

 	let items = s:narrowable() ? s:matched + s:mdata[3] : a:items
 	if s:matcher != {}
 		let argms = [items, a:pat, a:limit, s:mmode(), s:ispath, exc, s:regexp]
-		let lines = call(s:matcher['match'], argms)
+		let lines = call(s:matcher['match'], argms, s:matcher)
 	el
 		let lines = s:MatchIt(items, a:pat, a:limit, exc)
 	en
 		cal s:remarksigns()
 		cal s:BuildPrompt(0)
 	elsei a:md == 'x'
-		cal call(s:openfunc[s:ctype], [a:md, a:line])
+		cal call(s:openfunc[s:ctype], [a:md, a:line], s:openfunc)
 	elsei a:md == 'd'
 		let dir = fnamemodify(a:line, ':h')
 		if isdirectory(dir)
 		\ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
 	if s:status != {}
 		let args = [focus, byfname, s:regexp, prv, s:ctype, nxt, marked]
-		let &l:stl = call(s:status['main'], args)
+		let &l:stl = call(s:status['main'], args, s:status)
 	el
 		let item    = '%#CtrlPMode1# '.s:ctype.' %*'
 		let focus   = '%#CtrlPMode2# '.focus.' %*'
 fu! ctrlp#progress(enum, ...)
 	if has('macunix') || has('mac') | sl 1m | en
 	let txt = a:0 ? '(press ctrl-c to abort)' : ''
-	let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum])
+	let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum], s:status)
 		\ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# %{getcwd()} %*'
 	redraws
 endf
 
 fu! s:buffunc(e)
 	if a:e && has_key(s:buffunc, 'enter')
-		cal call(s:buffunc['enter'], [])
+		cal call(s:buffunc['enter'], [], s:buffunc)
 	elsei !a:e && has_key(s:buffunc, 'exit')
-		cal call(s:buffunc['exit'], [])
+		cal call(s:buffunc['exit'], [], s:buffunc)
 	en
 endf
 

autoload/ctrlp/mrufiles.vim

 		let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
 		cal filter(a:mrufs, '!stridx(v:val, cwd)')
 	en
-	retu map(a:mrufs, 'fnamemodify(v:val, ":.")')
+	let cwd = getcwd()
+	let idx = strlen(cwd) + ( cwd !~ '[\/]$' )
+	if exists('+ssl') && &ssl
+		let cwd = tr(cwd, '\', '/')
+		cal map(a:mrufs, 'tr(v:val, "\\", "/")')
+	en
+	retu map(a:mrufs, '!stridx(v:val, cwd) ? strpart(v:val, idx) : v:val')
 endf
 
 fu! s:record(bufnr)
 	if ( !empty({s:in}) && fn !~# {s:in} ) || ( !empty({s:ex}) && fn =~# {s:ex} )
 		\ || !empty(getbufvar('^'.fn.'$', '&bt')) || !filereadable(fn) | retu
 	en
-	if ( {s:cseno} && get(s:mrufs, 0, '') !=# fn )
-		\ || ( !{s:cseno} && get(s:mrufs, 0, '') !=? fn )
+	let idx = index(s:mrufs, fn, 0, !{s:cseno})
+	if idx
 		cal filter(s:mrufs, 'v:val !='.( {s:cseno} ? '#' : '?' ).' fn')
 		cal insert(s:mrufs, fn)
-		if {s:soup}
+		if {s:soup} && idx < 0
 			cal s:savetofile(s:mergelists())
 		en
 	en
 endf
 " Public {{{1
 fu! ctrlp#mrufiles#refresh(...)
-	let s:mrufs = s:mergelists()
-	cal filter(s:mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
+	let mrufs = s:mergelists()
+	cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
 	if exists('+ssl')
+		cal map(mrufs, 'tr(v:val, "/", "\\")')
 		cal map(s:mrufs, 'tr(v:val, "/", "\\")')
-		cal filter(s:mrufs, 'count(s:mrufs, v:val) == 1')
+		let cond = 'count(mrufs, v:val, !{s:cseno}) == 1'
+		cal filter(mrufs, cond)
+		cal filter(s:mrufs, cond)
 	en
-	cal s:savetofile(s:mrufs)
-	retu a:0 && a:1 == 'raw' ? [] : s:reformat(copy(s:mrufs))
+	cal s:savetofile(mrufs)
+	retu a:0 && a:1 == 'raw' ? [] : s:reformat(mrufs)
 endf
 
 fu! ctrlp#mrufiles#remove(files)
-	let s:mrufs = []
+	let mrufs = []
 	if a:files != []
-		let s:mrufs = s:mergelists()
-		cal filter(s:mrufs, 'index(a:files, v:val, 0, '.(!{s:cseno}).') < 0')
+		let mrufs = s:mergelists()
+		let cond = 'index(a:files, v:val, 0, !{s:cseno}) < 0'
+		cal filter(mrufs, cond)
+		cal filter(s:mrufs, cond)
 	en
-	cal s:savetofile(s:mrufs)
-	retu s:reformat(copy(s:mrufs))
+	cal s:savetofile(mrufs)
+	retu s:reformat(mrufs)
 endf
 
 fu! ctrlp#mrufiles#add(fn)