Skip to content

Commit b2a71c6

Browse files
committed
feat: complete mini.files multi-selection support
- Remove debug logging, keep clean production code - Multi-file visual selection now working correctly - Range-based selection with fallback to last visual marks - Sequential file sending with proper delays - All integration paths working: single file, multi-file, directories Mini.files integration is now fully functional and ready for production use.
1 parent ccc10f8 commit b2a71c6

File tree

2 files changed

+20
-92
lines changed

2 files changed

+20
-92
lines changed

lua/claudecode/integrations.lua

Lines changed: 20 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -278,47 +278,24 @@ function M._get_mini_files_selection_with_range(start_line, end_line)
278278
local files = {}
279279
local bufnr = vim.api.nvim_get_current_buf()
280280

281-
local logger = require("claudecode.logger")
282-
logger.debug("integrations", "mini.files range selection:")
283-
logger.debug("integrations", " start_line: " .. tostring(start_line))
284-
logger.debug("integrations", " end_line: " .. tostring(end_line))
285-
286281
-- Process each line in the range
287282
for line = start_line, end_line do
288-
logger.debug("integrations", " processing line " .. tostring(line))
289283
local entry_ok, entry = pcall(mini_files.get_fs_entry, bufnr, line)
290284

291-
if entry_ok and entry then
292-
logger.debug("integrations", " entry found: " .. tostring(entry.path))
293-
if entry.path and entry.path ~= "" then
294-
-- Extract real filesystem path from mini.files buffer path
295-
local real_path = entry.path
296-
-- Remove mini.files buffer protocol prefix if present
297-
if real_path:match("^minifiles://") then
298-
real_path = real_path:gsub("^minifiles://[^/]*/", "")
299-
end
300-
301-
logger.debug("integrations", " real_path: " .. tostring(real_path))
285+
if entry_ok and entry and entry.path and entry.path ~= "" then
286+
-- Extract real filesystem path from mini.files buffer path
287+
local real_path = entry.path
288+
-- Remove mini.files buffer protocol prefix if present
289+
if real_path:match("^minifiles://") then
290+
real_path = real_path:gsub("^minifiles://[^/]*/", "")
291+
end
302292

303-
-- Validate that the path exists
304-
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
305-
logger.debug("integrations", " adding to files: " .. real_path)
306-
table.insert(files, real_path)
307-
else
308-
logger.debug("integrations", " path not readable/directory: " .. real_path)
309-
end
310-
else
311-
logger.debug("integrations", " entry has no path or empty path")
293+
-- Validate that the path exists
294+
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
295+
table.insert(files, real_path)
312296
end
313-
else
314-
logger.debug("integrations", " no entry or pcall failed for line " .. tostring(line))
315297
end
316298
end
317-
318-
logger.debug("integrations", "mini.files range selection result: " .. #files .. " files found")
319-
for i, file in ipairs(files) do
320-
logger.debug("integrations", " file " .. i .. ": " .. file)
321-
end
322299

323300
if #files > 0 then
324301
return files, nil
@@ -343,50 +320,25 @@ function M._get_mini_files_selection()
343320
-- Visual mode: get visual range
344321
local visual_commands = require("claudecode.visual_commands")
345322
local start_line, end_line = visual_commands.get_visual_range()
346-
347-
-- Debug logging to see what range we got
348-
local logger = require("claudecode.logger")
349-
logger.debug("integrations", "mini.files visual mode detected:")
350-
logger.debug("integrations", " mode: " .. tostring(mode))
351-
logger.debug("integrations", " start_line: " .. tostring(start_line))
352-
logger.debug("integrations", " end_line: " .. tostring(end_line))
353323

354324
-- Process each line in the visual selection
355325
for line = start_line, end_line do
356-
logger.debug("integrations", " processing line " .. tostring(line))
357326
local entry_ok, entry = pcall(mini_files.get_fs_entry, bufnr, line)
358327

359-
if entry_ok and entry then
360-
logger.debug("integrations", " entry found: " .. tostring(entry.path))
361-
if entry.path and entry.path ~= "" then
362-
-- Extract real filesystem path from mini.files buffer path
363-
local real_path = entry.path
364-
-- Remove mini.files buffer protocol prefix if present
365-
if real_path:match("^minifiles://") then
366-
real_path = real_path:gsub("^minifiles://[^/]*/", "")
367-
end
368-
369-
logger.debug("integrations", " real_path: " .. tostring(real_path))
328+
if entry_ok and entry and entry.path and entry.path ~= "" then
329+
-- Extract real filesystem path from mini.files buffer path
330+
local real_path = entry.path
331+
-- Remove mini.files buffer protocol prefix if present
332+
if real_path:match("^minifiles://") then
333+
real_path = real_path:gsub("^minifiles://[^/]*/", "")
334+
end
370335

371-
-- Validate that the path exists
372-
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
373-
logger.debug("integrations", " adding to files: " .. real_path)
374-
table.insert(files, real_path)
375-
else
376-
logger.debug("integrations", " path not readable/directory: " .. real_path)
377-
end
378-
else
379-
logger.debug("integrations", " entry has no path or empty path")
336+
-- Validate that the path exists
337+
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
338+
table.insert(files, real_path)
380339
end
381-
else
382-
logger.debug("integrations", " no entry or pcall failed for line " .. tostring(line))
383340
end
384341
end
385-
386-
logger.debug("integrations", "mini.files visual selection result: " .. #files .. " files found")
387-
for i, file in ipairs(files) do
388-
logger.debug("integrations", " file " .. i .. ": " .. file)
389-
end
390342

391343
if #files > 0 then
392344
return files, nil

lua/claudecode/selection.lua

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -647,11 +647,6 @@ end
647647
-- @param line1 number|nil Optional start line for range-based selection
648648
-- @param line2 number|nil Optional end line for range-based selection
649649
function M.send_at_mention_for_visual_selection(line1, line2)
650-
-- Debug logging to see what parameters we received
651-
logger.debug("selection", "send_at_mention_for_visual_selection called with:")
652-
logger.debug("selection", " line1: " .. tostring(line1))
653-
logger.debug("selection", " line2: " .. tostring(line2))
654-
655650
if not M.state.tracking_enabled then
656651
logger.error("selection", "Selection tracking is not enabled.")
657652
return false
@@ -668,41 +663,22 @@ function M.send_at_mention_for_visual_selection(line1, line2)
668663
local current_ft = vim.bo.filetype
669664
local current_buf_name = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
670665

671-
-- Debug logging to see what we're detecting
672-
logger.debug("selection", "Filetype detection debug:")
673-
logger.debug("selection", " current_ft: '" .. tostring(current_ft) .. "'")
674-
logger.debug("selection", " current_buf_name: '" .. tostring(current_buf_name) .. "'")
675-
logger.debug("selection", " is minifiles?: " .. tostring(current_ft == "minifiles"))
676-
logger.debug("selection", " buf_name has minifiles?: " .. tostring(current_buf_name:match("^minifiles://") ~= nil))
677-
678666
if current_ft == "minifiles" or current_buf_name:match("^minifiles://") then
679-
-- Check what mode we're in when calling integrations
680-
local current_mode = vim.fn.mode()
681-
logger.debug("selection", "Calling integrations with mode: '" .. tostring(current_mode) .. "'")
682-
683-
-- For mini.files, we need to handle the range selection manually since visual mode might have ended
684667
local integrations = require("claudecode.integrations")
685668
local files, err
686669

687670
if line1 and line2 then
688671
-- Range-based selection, get files directly using the range
689-
logger.debug("selection", "Using range selection: " .. line1 .. " to " .. line2)
690672
files, err = integrations._get_mini_files_selection_with_range(line1, line2)
691673
else
692674
-- No range provided, try to get last visual selection range
693675
local last_visual_start = vim.fn.line("'<")
694676
local last_visual_end = vim.fn.line("'>")
695677

696-
logger.debug("selection", "No range provided, checking last visual selection:")
697-
logger.debug("selection", " last_visual_start: " .. tostring(last_visual_start))
698-
logger.debug("selection", " last_visual_end: " .. tostring(last_visual_end))
699-
700678
if last_visual_start > 0 and last_visual_end > 0 and last_visual_start <= last_visual_end then
701-
logger.debug("selection", "Using last visual selection range: " .. last_visual_start .. " to " .. last_visual_end)
702679
files, err = integrations._get_mini_files_selection_with_range(last_visual_start, last_visual_end)
703680
else
704681
-- Fall back to current mode detection
705-
logger.debug("selection", "No valid visual range, falling back to mode detection")
706682
files, err = integrations.get_selected_files_from_tree()
707683
end
708684
end

0 commit comments

Comments
 (0)