Skip to content

Commit

Permalink
Make LastMode also be able to restore last working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kien committed Sep 6, 2012
1 parent 4557b5e commit 1fd3760
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,15 @@ fu! s:PrtSwitcher()
endf
" - SetWD() {{{1
fu! s:SetWD(args)
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:wpmode
if has_key(a:args, 'args') && stridx(a:args['args'], '--dir') >= 0
\ && exists('s:dyncwd')
cal ctrlp#setdir(s:dyncwd) | retu
en
if has_key(a:args, 'dir') && a:args['dir'] != ''
cal ctrlp#setdir(a:args['dir']) | retu
en
let pmode = has_key(a:args, 'mode') ? a:args['mode'] : s:wpmode
let [s:crfilerel, s:dyncwd] = [fnamemodify(s:crfile, ':.'), getcwd()]
if s:crfile =~ '^.\+://' | retu | en
if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 )
\ || ( !type(pmode) && pmode )
Expand Down
5 changes: 3 additions & 2 deletions doc/ctrlp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,9 @@ COMMANDS *ctrlp-commands*
Open CtrlP in find Most-Recently-Used file mode.

*:CtrlPLastMode*
:CtrlPLastMode
Open CtrlP in the last mode used.
:CtrlPLastMode [--dir]
Open CtrlP in the last mode used. When having the "--dir" argument, also
reuse the last working directory.

*:CtrlPRoot*
:CtrlPRoot
Expand Down
2 changes: 1 addition & 1 deletion plugin/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': <q-args> })
com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': <q-args> })

com! -bar CtrlPBuffer cal ctrlp#init(1)
com! -bar CtrlPLastMode cal ctrlp#init(-1)
com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': <q-args> })

com! -bar CtrlPClearCache cal ctrlp#clr()
com! -bar CtrlPClearAllCaches cal ctrlp#clra()
Expand Down

0 comments on commit 1fd3760

Please sign in to comment.