@@ -82,9 +82,52 @@ function M._get_neotree_selection()
82
82
83
83
local files = {}
84
84
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
88
131
if selection and # selection > 0 then
89
132
logger .debug (" integrations" , " Found " .. # selection .. " selected items in neo-tree" )
90
133
for _ , node in ipairs (selection ) do
@@ -96,6 +139,8 @@ function M._get_neotree_selection()
96
139
if # files > 0 then
97
140
return files , nil
98
141
end
142
+ else
143
+ logger .debug (" integrations" , " No multi-selection found, falling back to cursor node" )
99
144
end
100
145
end
101
146
0 commit comments