Skip to content

fix(filesystem): ignore dotfiles properly for find filter #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lua/neo-tree/sources/filesystem/lib/filter_external.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ M.filter_files_external = function(
file_types[#file_types + 1] = file_type_map[k]
end
end
if ignore.dotfiles then
append("-name", ".*", "-prune", "-o")
end
if #file_types > 0 then
append("-type", table.concat(file_types, ","))
end
Expand All @@ -193,9 +196,6 @@ M.filter_files_external = function(
if types.executable then
append("-executable")
end
if not ignore.dotfiles then
append("-not", "-path", "*/.*")
end
Copy link
Collaborator

@pynappo pynappo Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it's obviously breaking but I don't know if it's necessarily redundant. Based on the code for fd, the intention seems to be to optionally exclude hidden folders and hopefully reduce the amount of lines from the external cmd that neo-tree has to process?

To get the same functionality as the 'fd' block, could you try this instead? seems to work on my end:

    -- right after `for k, v in pairs(types) do ... end`
    if ignore.dotfiles then
      append("-name", ".*", "-prune", "-o")
    end
    -- right before the call to append_find_args:
    -- explicitly print out entries since `-prune -o` may expect an expression after it
    append("-print")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I've tested with both enabled/disabled setting, works well so far

if glob ~= nil and not full_path then
append("-iname", glob)
elseif glob ~= nil and full_path then
Expand All @@ -205,6 +205,7 @@ M.filter_files_external = function(
elseif regex ~= nil then
append("-regextype", "sed", "-regex", regex)
end
append("-print")
append_find_args()
elseif cmd == "fzf" then
-- This does not work yet, there's some kind of issue with how fzf uses stdout
Expand Down