Skip to content

fix(snacks): invalid window on :ClaudeCodeFocus #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lua/claudecode/terminal/snacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down