Skip to content

Commit db8b522

Browse files
committed
fix: skip terminal open when claude is connected externally
1 parent d0f9748 commit db8b522

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lua/claudecode/init.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,18 @@ function M.send_at_mention(file_path, start_line, end_line, context)
324324

325325
-- Check if Claude Code is connected
326326
if M.is_claude_connected() then
327-
-- Claude is connected, send immediately and ensure terminal is visible
327+
-- Claude is connected, send immediately
328328
local success, error_msg = M._broadcast_at_mention(file_path, start_line, end_line)
329329
if success then
330+
-- Only ensure terminal is visible if there's already a terminal inside Neovim
331+
-- This prevents opening a terminal when Claude is connected externally
330332
local terminal = require("claudecode.terminal")
331-
terminal.ensure_visible()
333+
local active_bufnr = terminal.get_active_terminal_bufnr and terminal.get_active_terminal_bufnr()
334+
if active_bufnr then
335+
-- Terminal exists in Neovim, ensure it's visible
336+
terminal.ensure_visible()
337+
end
338+
-- If no terminal buffer exists, Claude is connected externally - don't open a new terminal
332339
end
333340
return success, error_msg
334341
else

0 commit comments

Comments
 (0)