@@ -658,7 +658,54 @@ function M._create_commands()
658
658
end
659
659
660
660
local function handle_send_visual (visual_data , _opts )
661
- -- Try tree file selection first
661
+ -- Check if we're in a tree buffer first
662
+ local current_ft = (vim .bo and vim .bo .filetype ) or " "
663
+ local current_bufname = (vim .api and vim .api .nvim_buf_get_name and vim .api .nvim_buf_get_name (0 )) or " "
664
+
665
+ local is_tree_buffer = current_ft == " NvimTree"
666
+ or current_ft == " neo-tree"
667
+ or current_ft == " oil"
668
+ or current_ft == " minifiles"
669
+ or string.match (current_bufname , " neo%-tree" )
670
+ or string.match (current_bufname , " NvimTree" )
671
+ or string.match (current_bufname , " minifiles://" )
672
+
673
+ if is_tree_buffer then
674
+ local integrations = require (" claudecode.integrations" )
675
+ local files , error
676
+
677
+ -- For mini.files, try to get the range from visual marks
678
+ if current_ft == " minifiles" or string.match (current_bufname , " minifiles://" ) then
679
+ local start_line = vim .fn .line (" '<" )
680
+ local end_line = vim .fn .line (" '>" )
681
+
682
+
683
+ if start_line > 0 and end_line > 0 and start_line <= end_line then
684
+ -- Use range-based selection for mini.files
685
+ files , error = integrations ._get_mini_files_selection_with_range (start_line , end_line )
686
+ else
687
+ -- Fall back to regular method
688
+ files , error = integrations .get_selected_files_from_tree ()
689
+ end
690
+ else
691
+ files , error = integrations .get_selected_files_from_tree ()
692
+ end
693
+
694
+ if error then
695
+ logger .error (" command" , " ClaudeCodeSend_visual->TreeAdd: " .. error )
696
+ return
697
+ end
698
+
699
+ if not files or # files == 0 then
700
+ logger .warn (" command" , " ClaudeCodeSend_visual->TreeAdd: No files selected" )
701
+ return
702
+ end
703
+
704
+ add_paths_to_claude (files , { context = " ClaudeCodeSend_visual->TreeAdd" })
705
+ return
706
+ end
707
+
708
+ -- Fall back to old visual selection logic for non-tree buffers
662
709
if visual_data then
663
710
local visual_commands = require (" claudecode.visual_commands" )
664
711
local files , error = visual_commands .get_files_from_visual_selection (visual_data )
0 commit comments