@@ -723,9 +723,6 @@ function s:MoveWin(w, other, below)
723723 noa exe win_id2win (p != a: w ? p : nw).' wincmd w'
724724 noa exe win_id2win (w != a: w ? w : nw).' wincmd w'
725725 noa exe win_id2win (a: w ).' close!'
726- call remove (col , i )
727- call s: Layout (col )
728- call s: Layout (s: WinCol (nw))
729726 endif
730727endfunc
731728
@@ -741,8 +738,6 @@ function s:NewCol(w)
741738 noa exe win_id2win (p ).' wincmd w'
742739 noa exe win_id2win (w ).' wincmd w'
743740 noa exe win_id2win (a: w ).' close!'
744- call remove (col , index (col , a: w ))
745- call s: Layout (col )
746741endfunc
747742
748743function s: Scroll (topline)
@@ -1177,18 +1172,32 @@ function s:BufWinLeave()
11771172 endif
11781173endfunc
11791174
1180- function s: WinClosed (w )
1181- if has_key (s: minimized , a: w )
1182- call remove (s: minimized , a: w )
1175+ function s: WinClosedPre ()
1176+ " Only works with 'nosplitbelow'
1177+ let w = expand (" <amatch>" )
1178+ let h = winheight (w ) + 1
1179+ let col = s: WinCol (w )
1180+ let [i , j ] = [index (col , w ), index (col , win_getid ())]
1181+ if j == -1
1182+ let fbelow = i + 1 == len (col ) ? ' ' :
1183+ \ fnamemodify (bufname (winbufnr (col [i + 1 ])), ' :t' )
1184+ if i == 0 || fbelow != ' guide'
1185+ return
1186+ endif
1187+ let j = i - 1
11831188 endif
1184- let col = s: WinCol (a: w )
1185- call remove (col , index (col , a: w ))
1186- call timer_start (0 , {_ - > s: Layout (col )})
1189+ let focus = w == win_getid ()
1190+ call timer_start (0 , {_ - > s: WinClosedPost (col [j ], i - j , h , focus)})
11871191endfunc
11881192
1189- function s: WinNew (w )
1190- let col = s: WinCol (a: w )
1191- call timer_start (0 , {_ - > s: Layout (col )})
1193+ function s: WinClosedPost (w , n , h , focus)
1194+ let w = win_id2win (a: w )
1195+ for i in a: n < 0 ? range (a: n + 1 , -1 ) : reverse (range (a: n ))
1196+ call win_move_statusline (w + i , a: n < 0 ? - a: h : a: h )
1197+ endfor
1198+ if a: focus
1199+ exe w .' wincmd w'
1200+ endif
11921201endfunc
11931202
11941203augroup acme_vim
@@ -1200,8 +1209,7 @@ au TextChanged,TextChangedI guide setl nomodified
12001209au VimEnter * call s: ReloadDirs (winnr ())
12011210au VimResized * call s: ReloadDirs (0 )
12021211au WinResized * call s: ReloadDirs (0 )
1203- au WinClosed * call s: WinClosed (str2nr (expand (" <amatch>" )))
1204- au WinNew * call s: WinNew (win_getid ())
1212+ au WinClosed * call s: WinClosedPre ()
12051213augroup END
12061214
12071215if exists (" s:ctrlexe" )
0 commit comments