trash/windows: list silently drops file entries in show_all_files mode #10

Closed
opened 2026-03-20 20:49:44 +00:00 by barrettruth · 0 comments
barrettruth commented 2026-03-20 20:49:44 +00:00

Problem

The `list` function in `lua/canola/adapters/trash/windows.lua` uses `vim.tbl_map`, which can only return one entry per source item. When `show_all_files = true` and an entry's original path is in a subdirectory of the current path, both the file-entry block and the directory-entry block execute for the same raw entry. The while loop in the directory block overwrites `cache_entry`, so the file entry is silently dropped and only the directory entry is returned.

The freedesktop adapter avoids this by using `table.insert` inside the callback to accumulate entries independently, allowing multiple entries per source item.

Solution

Restructure `list` to collect entries in a local list (like freedesktop does) instead of using `tbl_map`. This allows both the file entry and the intermediate directory entry to be emitted for the same raw item when `show_all_files = true`.

## Problem The \`list\` function in \`lua/canola/adapters/trash/windows.lua\` uses \`vim.tbl_map\`, which can only return one entry per source item. When \`show_all_files = true\` and an entry's original path is in a subdirectory of the current path, both the file-entry block and the directory-entry block execute for the same raw entry. The while loop in the directory block overwrites \`cache_entry\`, so the file entry is silently dropped and only the directory entry is returned. The freedesktop adapter avoids this by using \`table.insert\` inside the callback to accumulate entries independently, allowing multiple entries per source item. ## Solution Restructure \`list\` to collect entries in a local list (like freedesktop does) instead of using \`tbl_map\`. This allows both the file entry and the intermediate directory entry to be emitted for the same raw item when \`show_all_files = true\`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/canola-collection#10
No description provided.