diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index a74dcfc..218b7a8 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -83,7 +83,7 @@ let [s:pref, s:opts, s:new_opts] = ['g:ctrlp_', { \ 'use_caching': ['s:caching', 1], \ 'use_migemo': ['s:migemo', 0], \ 'user_command': ['s:usrcmd', ''], - \ 'working_path_mode': ['s:pathmode', 'rc'], + \ 'working_path_mode': ['s:pathmode', 'ra'], \ }, { \ 'open_multiple_files': 's:opmul', \ 'regexp': 's:regexp', @@ -827,7 +827,8 @@ fu! s:SetWD(args) cal ctrlp#setdir(a:args['dir']) | retu en if s:crfile =~ '^.\+://' | retu | en - if pmode =~ 'c' || ( !type(pmode) && pmode ) + if pmode =~ 'c' || ( pmode =~ 'a' && stridx(s:crfpath, s:cwd) < 0 ) + \ || ( !type(pmode) && pmode ) if exists('+acd') | let [s:glb_acd, &acd] = [&acd, 0] | en cal ctrlp#setdir(s:crfpath) en diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index d8263aa..f6174cd 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -163,18 +163,19 @@ Where to put the new tab page when opening one: > *'g:ctrlp_working_path_mode'* When starting up, CtrlP sets its local working directory according to this variable: > - let g:ctrlp_working_path_mode = 'rc' + let g:ctrlp_working_path_mode = 'ra' < c - the directory of the current file. r - the nearest ancestor that contains one of these directories or files: .git .hg .svn .bzr _darcs + a - like c, but only if the current working directory outside of CtrlP is not + a direct ancestor of the directory of the current file. 0 or - don't manage working directory. Note #1: you can use b:ctrlp_working_path_mode (a |b:var|) to set this option on a per buffer basis. -Note #2: with both 'r' and 'c' in the option, when a root isn't found, use the -directory of the current file. +Note #2: with 'ra' or 'rc', use the behavior of a or c when a root isn't found. *'g:ctrlp_root_markers'* Use this to set your own root markers in addition to the default ones (.git, @@ -673,7 +674,7 @@ COMMANDS *ctrlp-commands* *:CtrlPRoot* :CtrlPRoot - This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'rc' and ignores + This acts like |:CtrlP| with |g:ctrlp_working_path_mode| = 'r' and ignores the variable's current value. *:CtrlPClearCache* diff --git a/plugin/ctrlp.vim b/plugin/ctrlp.vim index f7d1b13..2b1314a 100644 --- a/plugin/ctrlp.vim +++ b/plugin/ctrlp.vim @@ -33,7 +33,7 @@ com! -bar ResetCtrlP cal ctrlp#reset() com! -bar CtrlPCurWD cal ctrlp#init(0, { 'mode': '' }) com! -bar CtrlPCurFile cal ctrlp#init(0, { 'mode': 'c' }) -com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'rc' }) +com! -bar CtrlPRoot cal ctrlp#init(0, { 'mode': 'r' }) if g:ctrlp_map != '' && !hasmapto(':'.g:ctrlp_cmd.'', 'n') exe 'nn ' g:ctrlp_map ':'.g:ctrlp_cmd.'' @@ -64,3 +64,5 @@ com! -bar CtrlPBookmarkDir cal ctrlp#init(ctrlp#bookmarkdir#id()) com! -n=? -com=dir CtrlPBookmarkDirAdd \ cal ctrlp#call('ctrlp#bookmarkdir#add', ) + +" vim:ts=2:sw=2:sts=2 diff --git a/readme.md b/readme.md index dd90c30..9c26753 100644 --- a/readme.md +++ b/readme.md @@ -47,13 +47,13 @@ Use `:diffthis` when opening multiple files to run `:diffthis` on the first 4 fi * When invoked, unless a starting directory is specified, CtrlP will set its local working directory according to this variable: ```vim - let g:ctrlp_working_path_mode = 'rc' + let g:ctrlp_working_path_mode = 'ra' ``` `'c'` - the directory of the current file. - `'r'` - the nearest ancestor that contains one of these directories or files: - `.git` `.hg` `.svn` `.bzr` `_darcs` - `0` or `''` (empty string) - don't manage working directory. + `'r'` - the nearest ancestor that contains one of these directories or files: `.git` `.hg` `.svn` `.bzr` `_darcs` + `'a'` - like c, but only if the current working directory outside of CtrlP is not a direct ancestor of the directory of the current file. + `0` or `''` (empty string) - disable this feature. Define additional root markers with the `g:ctrlp_root_markers` option.