Set winfixbuf on status windows

Resolves: https://github.com/tpope/vim-fugitive/issues/2272
This commit is contained in:
Tim Pope
2024-03-16 12:38:32 -04:00
parent 549e283d15
commit 8d4e8d4538

View File

@@ -4162,7 +4162,9 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args
try
let mods = s:Mods(a:mods, 'Edge')
let file = fugitive#Find(':', dir)
let arg = ' +setl\ foldmarker=<<<<<<<<,>>>>>>>>\|let\ w:fugitive_status=FugitiveGitDir() ' .
let arg = ' +setl\ foldmarker=<<<<<<<<,>>>>>>>>' .
\ (exists('&winfixbuf') ? '\ winfixbuf' : '') .
\ '\|let\ w:fugitive_status=FugitiveGitDir() ' .
\ s:fnameescape(file)
for tabnr in [tabpagenr()] + (mods =~# '\<tab\>' ? range(1, tabpagenr('$')) : [])
let bufs = tabpagebuflist(tabnr)
@@ -4176,6 +4178,9 @@ function! s:StatusCommand(line1, line2, range, count, bang, mods, reg, arg, args
exe winnr . 'wincmd w'
endif
let w:fugitive_status = dir
if exists('&winfixbuf')
setlocal winfixbuf
endif
1
return ''
endif
@@ -6203,7 +6208,7 @@ function! fugitive#DiffClose() abort
endfunction
function! s:BlurStatus() abort
if (&previewwindow || exists('w:fugitive_status')) && get(b:,'fugitive_type', '') ==# 'index'
if (&previewwindow || getwinvar(winnr(), '&winfixbuf') is# 1 || exists('w:fugitive_status')) && get(b:, 'fugitive_type', '') ==# 'index'
let winnrs = filter([winnr('#')] + range(1, winnr('$')), 's:UsableWin(v:val)')
if len(winnrs)
exe winnrs[0].'wincmd w'