Allow for numeric tab argument in <mods>

Support was added in Vim 9.0.0786.
This commit is contained in:
Tim Pope
2024-02-11 20:06:40 -05:00
parent ddedd5bd20
commit 2a388ef5ba

View File

@@ -140,7 +140,7 @@ endfunction
function! s:Mods(mods, ...) abort function! s:Mods(mods, ...) abort
let mods = substitute(a:mods, '\C<mods>', '', '') let mods = substitute(a:mods, '\C<mods>', '', '')
let mods = mods =~# '\S$' ? mods . ' ' : mods let mods = mods =~# '\S$' ? mods . ' ' : mods
if a:0 && mods !~# '\<\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>' if a:0 && mods !~# '\<\d*\%(aboveleft\|belowright\|leftabove\|rightbelow\|topleft\|botright\|tab\)\>'
let default = a:1 let default = a:1
if default ==# 'SpanOrigin' if default ==# 'SpanOrigin'
if s:OriginBufnr() > 0 && (mods =~# '\<vertical\>' ? &winfixheight : &winfixwidth) if s:OriginBufnr() > 0 && (mods =~# '\<vertical\>' ? &winfixheight : &winfixwidth)
@@ -1532,7 +1532,7 @@ function! s:QuickfixCreate(nr, opts) abort
endfunction endfunction
function! s:QuickfixOpen(nr, mods) abort function! s:QuickfixOpen(nr, mods) abort
let mods = substitute(s:Mods(a:mods), '\<tab\>', '', '') let mods = substitute(s:Mods(a:mods), '\<\d*tab\>', '', '')
return mods . (a:nr < 0 ? 'c' : 'l').'open' . (mods =~# '\<vertical\>' ? ' 20' : '') return mods . (a:nr < 0 ? 'c' : 'l').'open' . (mods =~# '\<vertical\>' ? ' 20' : '')
endfunction endfunction
@@ -3403,7 +3403,7 @@ function! s:RunEdit(state, tmp, job) abort
let sentinel = a:state.file . '.edit' let sentinel = a:state.file . '.edit'
let file = FugitiveVimPath(readfile(sentinel, '', 1)[0]) let file = FugitiveVimPath(readfile(sentinel, '', 1)[0])
try try
if !&equalalways && a:state.mods !~# '\<tab\>' && 3 > (a:state.mods =~# '\<vert' ? winwidth(0) : winheight(0)) if !&equalalways && a:state.mods !~# '\<\d*tab\>' && 3 > (a:state.mods =~# '\<vert' ? winwidth(0) : winheight(0))
let noequalalways = 1 let noequalalways = 1
setglobal equalalways setglobal equalalways
endif endif
@@ -6563,9 +6563,9 @@ function! fugitive#Diffsplit(autodir, keepfocus, mods, arg, ...) abort
return s:Mods(a:mods) . 'DiffGitCached' . (len(post) ? '|' . post : '') return s:Mods(a:mods) . 'DiffGitCached' . (len(post) ? '|' . post : '')
endif endif
let commit = s:DirCommitFile(@%)[1] let commit = s:DirCommitFile(@%)[1]
if a:mods =~# '\<tab\>' if a:mods =~# '\<\d*tab\>'
let mods = substitute(a:mods, '\<tab\>', '', 'g') let mods = substitute(a:mods, '\<\d*tab\>', '', 'g')
let pre = 'tab split' let pre = matchstr(a:mods, '\<\d*tab\>') . 'edit'
else else
let mods = 'keepalt ' . a:mods let mods = 'keepalt ' . a:mods
let pre = '' let pre = ''
@@ -7043,15 +7043,16 @@ function! s:BlameSubcommand(line1, count, range, bang, mods, options) abort
endif endif
return reload[1 : -1] return reload[1 : -1]
endif endif
if a:mods =~# '\<tab\>' let tabmod = matchstr(a:mods, '\<\d*tab\>')
silent tabedit % let mods = substitute(a:mods, '\<\d*tab\>', '', 'g')
if !empty(tabmod)
silent execute tabmod . 'edit %'
endif endif
let temp_state.origin_bufnr = bufnr('') let temp_state.origin_bufnr = bufnr('')
if exists('*win_getid') if exists('*win_getid')
let temp_state.origin_winid = win_getid() let temp_state.origin_winid = win_getid()
endif endif
let restore = [] let restore = []
let mods = substitute(a:mods, '\<tab\>', '', 'g')
for winnr in range(winnr('$'),1,-1) for winnr in range(winnr('$'),1,-1)
if getwinvar(winnr, '&scrollbind') if getwinvar(winnr, '&scrollbind')
if !&l:scrollbind if !&l:scrollbind