From da09f4b41579d70f961e19b7510a0b22efc9d112 Mon Sep 17 00:00:00 2001 From: Kien N Date: Sat, 7 Jul 2012 09:21:24 +0700 Subject: [PATCH] Extend tabpage_position --- autoload/ctrlp.vim | 26 ++++++++++++++++++++++---- doc/ctrlp.txt | 7 +++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index ea6add0..b206847 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -1023,6 +1023,9 @@ fu! s:OpenMulti(...) let [ic, cmds] = [1, { 'v': ['vert sb', 'vne'], 'h': ['sb', 'new'], \ 't': ['tab sb', 'tabe'] }] let [swb, &swb] = [&swb, ''] + if md == 't' && ctrlp#tabcount() < tabpagenr() + let s:tabct = ctrlp#tabcount() + en " Open the files for va in mkd let bufnr = bufnr('^'.va.'$') @@ -1044,7 +1047,7 @@ fu! s:OpenMulti(...) if jf | if ic == 2 let crpos = [tabpagenr(), winnr()] el - let crpos[0] += tabpagenr() == crpos[0] + let crpos[0] += tabpagenr() <= crpos[0] let crpos[1] += winnr() == crpos[1] en | en en @@ -1053,6 +1056,7 @@ fu! s:OpenMulti(...) exe ( md == 't' ? 'tabn '.crpos[0] : crpos[1].'winc w' ) en let &swb = swb + unl! s:tabct endf " ** Helper functions {{{1 " Sorting {{{2 @@ -1728,9 +1732,23 @@ fu! s:openfile(cmd, fid, tail, ...) endf fu! ctrlp#tabcount() - retu - \ s:tabpage == 'al' ? tabpagenr('$') : - \ s:tabpage == 'ac' ? '' : '' + if exists('s:tabct') + let tabct = s:tabct + let s:tabct += 1 + elsei !type(s:tabpage) + let tabct = s:tabpage + elsei type(s:tabpage) == 1 + let tabpos = + \ s:tabpage =~ 'c' ? tabpagenr() : + \ s:tabpage =~ 'f' ? 1 : + \ s:tabpage =~ 'l' ? tabpagenr('$') : + \ tabpagenr() + let tabct = + \ s:tabpage =~ 'a' ? tabpos : + \ s:tabpage =~ 'b' ? tabpos - 1 : + \ tabpos + en + retu tabct < 0 ? 0 : tabct endf fu! s:settype(type) diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 2e26ac5..58a13e1 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -150,8 +150,11 @@ Example: > Where to put the new tab page when opening one: > let g:ctrlp_tabpage_position = 'ac' < - al - after the last tab page. - ac - after the current tab page. + a - after. + b - before. + c - the current tab page. + l - the last tab page. + f - the first tab page. *'g:ctrlp_working_path_mode'* When starting up, CtrlP sets its local working directory according to this