From 32b0d6266361614a6a07cfe850750e900cd50575 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 2 May 2021 06:41:51 -0400 Subject: [PATCH] Hunt other tabs for window on :tab Git I'm not 100% sure if this is the correct (as in least surprising) behavior, but it seems like as good of place as any to start. Closes https://github.com/tpope/vim-fugitive/issues/1740 --- autoload/fugitive.vim | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 86b926a..10d2f70 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -3103,18 +3103,22 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args let file = fugitive#Find(':', dir) let arg = ' +let\ w:fugitive_status=FugitiveGitDir() ' . \ s:fnameescape(file) - for winnr in range(1, winnr('$')) - if s:cpath(file, fnamemodify(bufname(winbufnr(winnr)), ':p')) - if winnr == winnr() - call s:ReloadStatus() - else - call s:ExpireStatus(dir) - exe winnr . 'wincmd w' + for tabnr in [tabpagenr()] + (mods =~# '\' ? range(1, tabpagenr('$')) : []) + let bufs = tabpagebuflist(tabnr) + for winnr in range(1, tabpagewinnr(tabnr, '$')) + if s:cpath(file, fnamemodify(bufname(bufs[winnr-1]), ':p')) + if tabnr == tabpagenr() && winnr == winnr() + call s:ReloadStatus() + else + call s:ExpireStatus(dir) + exe tabnr . 'tabnext' + exe winnr . 'wincmd w' + endif + let w:fugitive_status = dir + 1 + return '' endif - let w:fugitive_status = dir - 1 - return '' - endif + endfor endfor if a:count ==# 0 return mods . 'edit' . (a:bang ? '!' : '') . arg