Skip to content

Fix path separator error only showing for existing directories#1939

Closed
ghost wants to merge 1 commit intomasterfrom
unknown repository
Closed

Fix path separator error only showing for existing directories#1939
ghost wants to merge 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Mar 21, 2026

Fixes #1873.

The path separator check in ensure_search_pattern_is_not_a_path only fired when the pattern was an existing directory (because of the .is_dir() gate). So fd / would error, but fd nonexistent/path would silently return nothing with no hint about what went wrong.

This removes the .is_dir() requirement so the error shows whenever the pattern contains a path separator. The "search inside this directory" hint still only shows when the path actually exists as a directory, since that suggestion only makes sense in that case.

Changes

  • src/main.rs: Remove .is_dir() gate, conditionally include directory hint
  • tests/tests.rs: Add test covering both existing and non-existing directory patterns

Test plan

cargo test test_error_if_pattern_contains_path_separator

1 new test, all existing tests still pass.

Previously, fd would only warn about path separators in the search
pattern when the pattern happened to be an existing directory. Patterns
like 'nonexistent/path' would silently return no results with no
indication of what went wrong.

Now the error fires whenever the pattern contains a path separator,
regardless of whether it exists on disk. The directory-specific hint
('use fd . <dir>') only shows when the path actually is a directory.

Fixes #1873
@ghost ghost closed this by deleting the head repository Mar 26, 2026
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The 'pattern contains path separator' error is only shown when pattern is an existing directory

0 participants