Skip to content

Commit 9062397

Browse files
committed
debug: add extensive logging to mini.files visual selection processing
1 parent 13e0ce1 commit 9062397

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

lua/claudecode/integrations.lua

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,25 +284,51 @@ function M._get_mini_files_selection()
284284
-- Visual mode: get visual range
285285
local visual_commands = require("claudecode.visual_commands")
286286
local start_line, end_line = visual_commands.get_visual_range()
287+
288+
-- Debug logging to see what range we got
289+
local logger = require("claudecode.logger")
290+
logger.debug("integrations", "mini.files visual mode detected:")
291+
logger.debug("integrations", " mode: " .. tostring(mode))
292+
logger.debug("integrations", " start_line: " .. tostring(start_line))
293+
logger.debug("integrations", " end_line: " .. tostring(end_line))
287294

288295
-- Process each line in the visual selection
289296
for line = start_line, end_line do
297+
logger.debug("integrations", " processing line " .. tostring(line))
290298
local entry_ok, entry = pcall(mini_files.get_fs_entry, bufnr, line)
291-
if entry_ok and entry and entry.path and entry.path ~= "" then
292-
-- Extract real filesystem path from mini.files buffer path
293-
local real_path = entry.path
294-
-- Remove mini.files buffer protocol prefix if present
295-
if real_path:match("^minifiles://") then
296-
real_path = real_path:gsub("^minifiles://[^/]*/", "")
297-
end
299+
300+
if entry_ok and entry then
301+
logger.debug("integrations", " entry found: " .. tostring(entry.path))
302+
if entry.path and entry.path ~= "" then
303+
-- Extract real filesystem path from mini.files buffer path
304+
local real_path = entry.path
305+
-- Remove mini.files buffer protocol prefix if present
306+
if real_path:match("^minifiles://") then
307+
real_path = real_path:gsub("^minifiles://[^/]*/", "")
308+
end
309+
310+
logger.debug("integrations", " real_path: " .. tostring(real_path))
298311

299-
-- Validate that the path exists
300-
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
301-
table.insert(files, real_path)
312+
-- Validate that the path exists
313+
if vim.fn.filereadable(real_path) == 1 or vim.fn.isdirectory(real_path) == 1 then
314+
logger.debug("integrations", " adding to files: " .. real_path)
315+
table.insert(files, real_path)
316+
else
317+
logger.debug("integrations", " path not readable/directory: " .. real_path)
318+
end
319+
else
320+
logger.debug("integrations", " entry has no path or empty path")
302321
end
322+
else
323+
logger.debug("integrations", " no entry or pcall failed for line " .. tostring(line))
303324
end
304325
end
305326

327+
logger.debug("integrations", "mini.files visual selection result: " .. #files .. " files found")
328+
for i, file in ipairs(files) do
329+
logger.debug("integrations", " file " .. i .. ": " .. file)
330+
end
331+
306332
if #files > 0 then
307333
return files, nil
308334
end

0 commit comments

Comments
 (0)