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