From bfbbbafa869f6421316773128a2fd20df7d7d8d0 Mon Sep 17 00:00:00 2001 From: Kien N Date: Thu, 10 May 2012 09:11:09 +0700 Subject: [PATCH] Extend '..' input --- autoload/ctrlp.vim | 14 +++++--------- doc/ctrlp.txt | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index a6110f2..197568c 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -863,9 +863,10 @@ fu! ctrlp#acceptfile(mode, line, ...) endf fu! s:SpecInputs(str) - if a:str == '..' && s:spi - cal s:parentdir(s:dyncwd) - cal ctrlp#setlines() + if a:str =~ '^\.\.\.*$' && s:spi + let cwd = s:dyncwd + cal ctrlp#setdir('../'.repeat('../', strlen(a:str) - 2)) + if cwd != s:dyncwd | cal ctrlp#setlines() | en cal s:PrtClear() retu 1 elsei a:str == s:lash && s:spi @@ -890,7 +891,7 @@ fu! s:AcceptSelection(mode) " Get the selected line let line = !empty(s:lines) ? s:lines[line('.') - 1] : '' if a:mode != 'e' && !s:itemtype && line == '' - \ && str !~ '\v^(\.\.|/|\\|\?|\@.+)$' + \ && str !~ '\v^(\.\.\.*|/|\\|\?|\@.+)$' cal s:CreateNewFile(a:mode) | retu en if empty(line) | retu | en @@ -1248,11 +1249,6 @@ fu! ctrlp#rmbasedir(items) retu a:items endf -fu! s:parentdir(curr) - let parent = s:getparent(a:curr) - if parent != a:curr | cal ctrlp#setdir(parent) | en -endf - fu! s:getparent(item) let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '') if parent == '' || match(parent, '[\/]') < 0 diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index b00aa8e..d4b8447 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -746,8 +746,15 @@ c) End the string with a colon ':' followed by a Vim command to execute that See also: Vim's |++opt| and |+cmd|. -d) Submit two dots '..' to go backward the directory tree by 1 level. If the - parent directory is large and uncached, this can be slow. +d) Submit two dots '..' to go backward the directory tree by 1 level. To go + backward multiple levels, use one extra dot for each extra level: +> + Raw input Interpreted as + .. ../ + ... ../../ + .... ../../../ +< + Note: if the parent directories are large and uncached, this can be slow. You can also use '@cd path/' to change CtrlP's local working directory. Use '@cd %:h' to change to the directory of the current file. @@ -1011,6 +1018,9 @@ Special thanks:~ =============================================================================== CHANGELOG *ctrlp-changelog* +Before 2012/05/15~ + + + Extend '..' (|ctrlp-input-formats| (d)) + New input format: '@cd' (|ctrlp-input-formats| (d)) Before 2012/04/30~