[READ-ONLY] Mirror of https://github.com/usrrname/dotfiles. There was an attempt to store my configs
shovelware nix-pkgs nix
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(nvim): guard opencode autocmd against closing last window

BufWinEnter autocmd closed current_win unconditionally when term
buf entered window. After toggling opencode off then reopening,
file window was current -> closed -> E444 (last regular window).
Now: only close dupes actually showing term buf, skip if <=1
regular win remains.

usrrname (Jul 5, 2026, 8:58 PM EDT) 4ba9975e c91f30e1

+19 -5
+19 -5
common/nvim/.config/nvim/lua/plugins/opencode.lua
··· 107 107 return 108 108 end 109 109 110 - local current_win = vim.api.nvim_get_current_win() 111 - if current_win == term.win then 112 - return 113 - end 110 + local current_win = vim.api.nvim_get_current_win() 111 + if current_win == term.win then 112 + return 113 + end 114 114 115 - vim.api.nvim_win_close(current_win, true) 115 + -- Only close if current_win is an unwanted duplicate showing 116 + -- the term buf (the actual misuse this autocmd guards against). 117 + if vim.api.nvim_win_get_buf(current_win) ~= buf then 118 + return 119 + end 120 + 121 + -- Never close the last regular window — E444. 122 + local regular_wins = vim.tbl_filter(function(w) 123 + return vim.api.nvim_win_get_config(w).relative == "" 124 + end, vim.api.nvim_list_wins()) 125 + if #regular_wins <= 1 then 126 + return 127 + end 128 + 129 + vim.api.nvim_win_close(current_win, true) 116 130 end, 10) 117 131 end, 118 132 })