Skip to content

Commit 24ff09a

Browse files
blink-so[bot]ThomasK33
andcommitted
fix: improve neo-tree multi-selection detection and clean up logging
- Remove redundant vim.notify call from ClaudeCodeTreeAdd - Enhance neo-tree multi-selection detection with multiple fallback methods - Add comprehensive debug logging to identify which selection method works - Try get_selection(), is_selected nodes, and state.selected_nodes approaches - Better error handling and debugging for neo-tree integration Co-authored-by: ThomasK33 <[email protected]>
1 parent 4a38550 commit 24ff09a

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

lua/claudecode/init.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ function M._create_commands()
356356
vim.api.nvim_create_user_command("ClaudeCodeTreeAdd", function()
357357
if not M.state.server then
358358
logger.error("command", "ClaudeCodeTreeAdd: Claude Code integration is not running.")
359-
vim.notify("Claude Code integration is not running", vim.log.levels.ERROR)
360359
return
361360
end
362361

lua/claudecode/integrations.lua

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,52 @@ function M._get_neotree_selection()
8282

8383
local files = {}
8484

85-
-- Check for multi-selection first
86-
if state.tree and state.tree.get_selection then
87-
local selection = state.tree:get_selection()
85+
-- Debug: Check what methods are available
86+
if state.tree then
87+
logger.debug("integrations", "neo-tree state.tree available, checking for selection methods")
88+
89+
-- Try different approaches for multi-selection
90+
local selection = nil
91+
92+
-- Method 1: get_selection
93+
if state.tree.get_selection then
94+
selection = state.tree:get_selection()
95+
logger.debug(
96+
"integrations",
97+
"get_selection method available, selection count: " .. (selection and #selection or "nil")
98+
)
99+
else
100+
logger.debug("integrations", "get_selection method not available")
101+
end
102+
103+
-- Method 2: Check for selected nodes directly
104+
if not selection or #selection == 0 then
105+
if state.tree.get_nodes then
106+
local nodes = state.tree:get_nodes()
107+
if nodes then
108+
for _, node in ipairs(nodes) do
109+
if node.is_selected or (node.extra and node.extra.is_selected) then
110+
selection = selection or {}
111+
table.insert(selection, node)
112+
logger.debug(
113+
"integrations",
114+
"Found selected node via is_selected: " .. (node.path or node.name or "unknown")
115+
)
116+
end
117+
end
118+
end
119+
end
120+
end
121+
122+
-- Method 3: Try to get selected items via neo-tree's selection state
123+
if not selection or #selection == 0 then
124+
if state.selected_nodes then
125+
selection = state.selected_nodes
126+
logger.debug("integrations", "Using state.selected_nodes, count: " .. #selection)
127+
end
128+
end
129+
130+
-- Process the selection if found
88131
if selection and #selection > 0 then
89132
logger.debug("integrations", "Found " .. #selection .. " selected items in neo-tree")
90133
for _, node in ipairs(selection) do
@@ -96,6 +139,8 @@ function M._get_neotree_selection()
96139
if #files > 0 then
97140
return files, nil
98141
end
142+
else
143+
logger.debug("integrations", "No multi-selection found, falling back to cursor node")
99144
end
100145
end
101146

0 commit comments

Comments
 (0)