Skip to content

Perform lazy update only on delete #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'jump_to_buffer': ['s:jmptobuf', 'Et'],
\ 'key_loop': ['s:keyloop', 0],
\ 'lazy_update': ['s:lazy', 0],
\ 'lazy_del': ['s:lazy_del', 0],
\ 'match_func': ['s:matcher', {}],
\ 'match_window': ['s:mw', ''],
\ 'match_window_bottom': ['s:mwbottom', 1],
Expand Down Expand Up @@ -271,6 +272,9 @@ fu! s:opts(...)
if s:lazy
cal extend(s:glbs, { 'ut': ( s:lazy > 1 ? s:lazy : 250 ) })
en
if s:lazy_del
cal extend(s:glbs, { 'ut': ( s:lazy_del > 1 ? s:lazy_del : 250 ) })
en
" Extensions
if !( exists('extensions') && extensions == s:extensions )
for each in s:extensions
Expand Down Expand Up @@ -693,6 +697,7 @@ endf
fu! s:ForceUpdate()
let pos = exists('*getcurpos') ? getcurpos() : getpos('.')
sil! cal s:Update(escape(s:getinput(), '\'))
let input = s:getinput()
cal setpos('.', pos)
endf

Expand Down Expand Up @@ -758,7 +763,11 @@ fu! s:PrtBS()
en
unl! s:hstgot
let [s:prompt[0], s:matches] = [substitute(s:prompt[0], '.$', '', ''), 1]
cal s:BuildPrompt(1)
if s:lazy_del
cal s:BuildPrompt(0)
el
cal s:BuildPrompt(1)
en
endf

fu! s:PrtDelete()
Expand All @@ -767,7 +776,11 @@ fu! s:PrtDelete()
let [prt, s:matches] = [s:prompt, 1]
let prt[1] = matchstr(prt[2], '^.')
let prt[2] = substitute(prt[2], '^.', '', '')
cal s:BuildPrompt(1)
if s:lazy_del
cal s:BuildPrompt(0)
el
cal s:BuildPrompt(1)
en
endf

fu! s:PrtDeleteWord()
Expand All @@ -779,7 +792,11 @@ fu! s:PrtDeleteWord()
\ : str =~ '\s\+$' ? matchstr(str, '^.*\S\ze\s\+$')
\ : str =~ '\v^(\S+|\s+)$' ? '' : str
let s:prompt[0] = str
cal s:BuildPrompt(1)
if s:lazy_del
cal s:BuildPrompt(0)
el
cal s:BuildPrompt(1)
en
endf

fu! s:PrtInsert(...)
Expand Down Expand Up @@ -2644,7 +2661,7 @@ fu! s:autocmds()
if exists('#CtrlPLazy')
au! CtrlPLazy
en
if s:lazy
if s:lazy || s:lazy_del
aug CtrlPLazy
au!
au CursorHold ControlP cal s:ForceUpdate()
Expand Down