[BUG] ClaudeCodeSend leaves source buffer in insert mode (snacks provider, focus_after_send off)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- vim
- 领域
- devtools
调研方向
Start with send_at_mention in init.lua, which calls terminal.ensure_visible() after a successful send, then follow the fallback to ensure_terminal_visible_no_focus in terminal.lua for the snacks provider. Check whether the snacks buffer-local auto_insert BufEnter autocmd leaves a pending startinsert after the terminal is shown without focus. Done means the source window stays in its current mode after :ClaudeCodeSend when focus_after_send is off, with no change to focus-on behaviour.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
With the snacks provider and focus_after_send off (the default), sending a visual selection with :ClaudeCodeSend leaves the source buffer in insert mode. Focus is correctly kept on the source window, but Neovim is in insert mode there, so the next keystrokes are typed into the buffer.
To reproduce
- Use the snacks terminal provider with default
terminal.auto_insertandfocus_after_send = false. - Start Claude, then hide the terminal.
- In a normal file, select text in visual mode and run
:ClaudeCodeSend(mapped as<cmd>ClaudeCodeSend<cr>in visual mode). - The terminal is shown again and focus returns to the source window, which is now in insert mode.
Expected
Focus and mode of the source window are unchanged when focus_after_send is off.
Likely cause (not fully verified)
init.lua send_at_mention calls terminal.ensure_visible() after a successful send. The snacks provider has no ensure_visible, so terminal.lua falls back to ensure_terminal_visible_no_focus, which opens or shows the terminal. Entering the terminal buffer appears to trigger snacks' buffer-local auto_insert BufEnter autocmd, which runs startinsert. Focus then moves back to the source window, but the pending insert carries over. I did not trace which exact call triggers it.
Workaround
A User ClaudeCodeSendComplete autocmd that cancels the insert:
vim.api.nvim_create_autocmd("User", {
pattern = "ClaudeCodeSendComplete",
callback = function()
local function fix()
if vim.bo.buftype ~= "terminal" then
vim.cmd("stopinsert")
end
end
fix()
vim.schedule(fix)
end,
})
Setting terminal.auto_insert = false also avoids it, but then focusing Claude no longer enters insert mode.
Suggested fix
When ensure_visible opens or shows the terminal without focus, do not leave a pending startinsert. For example, run the show with snacks auto_insert/start_insert disabled, or call stopinsert when the current window is not the terminal after showing it.
Related
#145 and #232 cover focusing the terminal. This one is about the unfocused path.
- 主要语言
- Lua
- 星标
- 3.1k
- 派生
- 223
- 平均合并
- 6 小时 47 分钟
- 30 天内合并 PR
- 93
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/claudecode.nvim 的其他 Issue
-
[BUG] ClaudeCodeAdd fails on paths with spaces可能已有人在做 @7A1T 于 80 天前认领。 未关闭bug needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
coder/claudecode.nvim#314 ·
维护者通常 1 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
coder/claudecode.nvim#313 ·
维护者通常 1 天内回复
-
needs-triage
难度 3/5 1-2 天 新手友好度 30/100
coder/claudecode.nvim#434 ·
维护者通常 1 天内回复
-
needs-triage
难度 5/5 一周以上 新手友好度 12/100
coder/claudecode.nvim#433 ·
维护者通常 1 天内回复
-
needs-triage
难度 3/5 1-2 天 新手友好度 62/100
coder/claudecode.nvim#309 ·
维护者通常 1 天内回复
查看 coder/claudecode.nvim 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
rohit746/pdf-view.nvim#107 ·
维护者通常 1 天内回复
-
bug guide
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
enhancement forever
难度 2/5 1-3 小时 新手友好度 61/100
openmap-world/openmap#78 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
AndyHazz/bookends.koplugin#130 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
carlos-algms/agentic.nvim#336 ·