@@ -642,6 +642,18 @@ function M.focus_output(should_stop_insert)
642642 vim .api .nvim_set_current_win (state .windows .output_win )
643643end
644644
645+ --- Restore winfix options on a window so they don't linger if the window
646+ --- survives (e.g. after buffer deletion or when Neovim reuses the window).
647+ --- @param win integer
648+ function M .restore_winfix_options (win )
649+ if not win or not vim .api .nvim_win_is_valid (win ) then
650+ return
651+ end
652+ pcall (vim .api .nvim_set_option_value , ' winfixbuf' , false , { win = win })
653+ pcall (vim .api .nvim_set_option_value , ' winfixheight' , false , { win = win })
654+ pcall (vim .api .nvim_set_option_value , ' winfixwidth' , false , { win = win })
655+ end
656+
645657--- Close and delete the output window and buffer.
646658function M .close ()
647659 if not M .mounted () then
@@ -650,6 +662,7 @@ function M.close()
650662 --- @cast state.windows { output_win : integer , output_buf : integer }
651663
652664 M .reset_scroll_tracking (state .windows .output_win )
665+ M .restore_winfix_options (state .windows .output_win )
653666 pcall (vim .api .nvim_win_close , state .windows .output_win , true )
654667 pcall (vim .api .nvim_buf_delete , state .windows .output_buf , { force = true })
655668end
@@ -770,6 +783,17 @@ function M.setup_autocmds(windows, group)
770783 end
771784 end ,
772785 })
786+
787+ -- Restore winfixbuf etc. when the output buffer is removed from the window,
788+ vim .api .nvim_create_autocmd (' BufDelete' , {
789+ group = group ,
790+ buffer = windows .output_buf ,
791+ callback = function ()
792+ if windows .output_win and vim .api .nvim_win_is_valid (windows .output_win ) then
793+ M .restore_winfix_options (windows .output_win )
794+ end
795+ end ,
796+ })
773797end
774798
775799--- Clear the output buffer and all namespaces.
0 commit comments