Bug Description
ClaudeCodeSend misclassifies a regular file buffer as a "tree buffer" when the file path (not filetype) contains the substring neo-tree, NvimTree, or minifiles://. This causes visual selection sends to fail with:
ClaudeCode Error [ClaudeCode] [command] [ERROR] ClaudeCodeSend_visual->TreeAdd: Not in visual mode (current mode: n)
The root cause is in lua/claudecode/init.lua, where is_tree_buffer is determined by both filetype and substring matching against the buffer name:
local is_tree_buffer = current_ft == "NvimTree"
or current_ft == "neo-tree"
or current_ft == "oil"
or current_ft == "minifiles"
or current_ft == "netrw"
or string.match(current_bufname, "neo%-tree") -- ← false positive
or string.match(current_bufname, "NvimTree") -- ← false positive
or string.match(current_bufname, "minifiles://")
When a user opens a file whose path contains one of those substrings (for example a Neovim config file named _neo-tree.lua, or anything under a directory called nvim-tree-config/), is_tree_buffer evaluates to true even though filetype is something like lua. The visual handler then tries to use tree-specific extraction via get_files_from_visual_selection, but:
capture_visual_selection_data() returns nil because get_tree_state() correctly returns nil for a non-tree buffer.
- ESC has already been fed to exit visual mode.
get_files_from_visual_selection(nil) calls validate_visual_mode(), which fails because we're now in normal mode → error logged.
This also affects the handle_send_normal path at lines 732-740 with the same string.match checks.
To Reproduce
Steps to reproduce:
- Create a file whose path contains the substring
neo-tree, e.g. ~/.config/nvim/lua/plugins/_neo-tree_.lua.
- Open it in Neovim:
nvim ~/.config/nvim/lua/plugins/_neo-tree_.lua.
- Start Claude Code:
:ClaudeCodeStart (or whichever command you use).
- In the lua buffer, visually select a few lines and run
:'<,'>ClaudeCodeSend (or the user's <leader>as mapping which calls ClaudeCodeSend).
Expected: the visual selection is sent to Claude.
Actual: error notification ClaudeCodeSend_visual->TreeAdd: Not in visual mode (current mode: n), nothing is sent.
Files whose paths do not contain neo-tree / NvimTree / minifiles:// work fine — which is why this bug appears intermittent (some files send, some don't).
Expected Behavior
is_tree_buffer should be determined by filetype only. The string.match(current_bufname, ...) checks are false positives — a regular file whose path happens to contain those substrings is not a tree buffer.
Environment
- Neovim version: NVIM v0.12.2
- Claude Code CLI version: 2.1.153
- OS: macOS 15
- Plugin version: 0.3.0 (commit
e6c9dd4d4f144910b0066489100ad94b7133821f)
Suggested Fix
Remove the string.match(current_bufname, ...) lines from both handle_send_normal (around line 738-740) and handle_send_visual (around line 793-795). The filetype checks above them are sufficient and correct.
local is_tree_buffer = current_ft == "NvimTree"
or current_ft == "neo-tree"
or current_ft == "oil"
or current_ft == "minifiles"
or current_ft == "netrw"
- or string.match(current_bufname, "neo%-tree")
- or string.match(current_bufname, "NvimTree")
- or string.match(current_bufname, "minifiles://")
The minifiles:// check may still be needed if minifiles uses a virtual buffer name without setting filetype = "minifiles" — worth confirming with the minifiles integration. But the neo-tree and NvimTree substring checks appear redundant with the filetype checks and should be safe to remove.
Additional Context
Workaround for affected users: rename files so their paths don't contain neo-tree / NvimTree, or map the send key to a custom wrapper that calls send_at_mention_for_visual_selection directly instead of ClaudeCodeSend.
Bug Description
ClaudeCodeSendmisclassifies a regular file buffer as a "tree buffer" when the file path (not filetype) contains the substringneo-tree,NvimTree, orminifiles://. This causes visual selection sends to fail with:The root cause is in
lua/claudecode/init.lua, whereis_tree_bufferis determined by both filetype and substring matching against the buffer name:When a user opens a file whose path contains one of those substrings (for example a Neovim config file named
_neo-tree.lua, or anything under a directory callednvim-tree-config/),is_tree_bufferevaluates totrueeven thoughfiletypeis something likelua. The visual handler then tries to use tree-specific extraction viaget_files_from_visual_selection, but:capture_visual_selection_data()returnsnilbecauseget_tree_state()correctly returnsnilfor a non-tree buffer.get_files_from_visual_selection(nil)callsvalidate_visual_mode(), which fails because we're now in normal mode → error logged.This also affects the
handle_send_normalpath at lines 732-740 with the samestring.matchchecks.To Reproduce
Steps to reproduce:
neo-tree, e.g.~/.config/nvim/lua/plugins/_neo-tree_.lua.nvim ~/.config/nvim/lua/plugins/_neo-tree_.lua.:ClaudeCodeStart(or whichever command you use).:'<,'>ClaudeCodeSend(or the user's<leader>asmapping which callsClaudeCodeSend).Expected: the visual selection is sent to Claude.
Actual: error notification
ClaudeCodeSend_visual->TreeAdd: Not in visual mode (current mode: n), nothing is sent.Files whose paths do not contain
neo-tree/NvimTree/minifiles://work fine — which is why this bug appears intermittent (some files send, some don't).Expected Behavior
is_tree_buffershould be determined byfiletypeonly. Thestring.match(current_bufname, ...)checks are false positives — a regular file whose path happens to contain those substrings is not a tree buffer.Environment
e6c9dd4d4f144910b0066489100ad94b7133821f)Suggested Fix
Remove the
string.match(current_bufname, ...)lines from bothhandle_send_normal(around line 738-740) andhandle_send_visual(around line 793-795). The filetype checks above them are sufficient and correct.local is_tree_buffer = current_ft == "NvimTree" or current_ft == "neo-tree" or current_ft == "oil" or current_ft == "minifiles" or current_ft == "netrw" - or string.match(current_bufname, "neo%-tree") - or string.match(current_bufname, "NvimTree") - or string.match(current_bufname, "minifiles://")The
minifiles://check may still be needed ifminifilesuses a virtual buffer name without settingfiletype = "minifiles"— worth confirming with the minifiles integration. But theneo-treeandNvimTreesubstring checks appear redundant with the filetype checks and should be safe to remove.Additional Context
Workaround for affected users: rename files so their paths don't contain
neo-tree/NvimTree, or map the send key to a custom wrapper that callssend_at_mention_for_visual_selectiondirectly instead ofClaudeCodeSend.