Permalink
Browse files

Make LastMode also be able to restore last working directory

  • Loading branch information...
1 parent 4557b5e commit 1fd3760b9483ff2acce08ff952d504a24795d9cf @kien committed Sep 3, 2012
Showing with 10 additions and 5 deletions.
  1. +6 −2 autoload/ctrlp.vim
  2. +3 −2 doc/ctrlp.txt
  3. +1 −1 plugin/ctrlp.vim
View
@@ -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 )
View
@@ -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
View
@@ -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()

0 comments on commit 1fd3760

Please sign in to comment.