diff --git a/lua/claudecode/terminal/snacks.lua b/lua/claudecode/terminal/snacks.lua index 30c2b46..ad19f41 100644 --- a/lua/claudecode/terminal/snacks.lua +++ b/lua/claudecode/terminal/snacks.lua @@ -167,11 +167,11 @@ function M.simple_toggle(cmd_string, env_table, config) local logger = require("claudecode.logger") -- Check if terminal exists and is visible - if terminal and terminal:buf_valid() and terminal.win then + if terminal and terminal:buf_valid() and terminal:win_valid() then -- Terminal is visible, hide it logger.debug("terminal", "Simple toggle: hiding visible terminal") terminal:toggle() - elseif terminal and terminal:buf_valid() and not terminal.win then + elseif terminal and terminal:buf_valid() and not terminal:win_valid() then -- Terminal exists but not visible, show it logger.debug("terminal", "Simple toggle: showing hidden terminal") terminal:toggle() @@ -195,11 +195,11 @@ function M.focus_toggle(cmd_string, env_table, config) local logger = require("claudecode.logger") -- Terminal exists, is valid, but not visible - if terminal and terminal:buf_valid() and not terminal.win then + if terminal and terminal:buf_valid() and not terminal:win_valid() then logger.debug("terminal", "Focus toggle: showing hidden terminal") terminal:toggle() -- Terminal exists, is valid, and is visible - elseif terminal and terminal:buf_valid() and terminal.win then + elseif terminal and terminal:buf_valid() and terminal:win_valid() then local claude_term_neovim_win_id = terminal.win local current_neovim_win_id = vim.api.nvim_get_current_win()