From 1fd3760b9483ff2acce08ff952d504a24795d9cf Mon Sep 17 00:00:00 2001 From: Kien N Date: Mon, 3 Sep 2012 23:10:26 +0700 Subject: [PATCH] Make LastMode also be able to restore last working directory --- autoload/ctrlp.vim | 8 ++++++-- doc/ctrlp.txt | 5 +++-- plugin/ctrlp.vim | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 218b7a8..bb999dd 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -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 ) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index f6174cd..32115ae 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -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 diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index 2b1314a..83190ce 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -21,7 +21,7 @@ com! -n=? -com=dir CtrlP cal ctrlp#init(0, { 'dir': }) com! -n=? -com=dir CtrlPMRUFiles cal ctrlp#init(2, { 'dir': }) com! -bar CtrlPBuffer cal ctrlp#init(1) -com! -bar CtrlPLastMode cal ctrlp#init(-1) +com! -n=? CtrlPLastMode cal ctrlp#init(-1, { 'args': }) com! -bar CtrlPClearCache cal ctrlp#clr() com! -bar CtrlPClearAllCaches cal ctrlp#clra()