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

Closed
opened 2026-09-21 17:53:33 +00:00 by barrettruth · 0 comments
Owner

Original issue: barrettruth/canola-collection#10
Original author: barrettruth
Original date: 2026-03-20T20:49:44Z

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`.

> Original issue: barrettruth/canola-collection#10 > Original author: `barrettruth` > Original date: 2026-03-20T20:49:44Z ## 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 description provided.