Skip to content

Commit 0f5ead1

Browse files
fix: Do not treat single token as a path name prefitler (#421)
* fix: Do not treat single token as a path name prefitler closes #420 * chore: Update docs for - fix: Do not treat single token as a path name prefitler
1 parent 84ba575 commit 0f5ead1

3 files changed

Lines changed: 4 additions & 49 deletions

File tree

crates/fff-query-parser/src/config.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,10 @@ pub trait ParserConfig {
9191
has_wildcards(token)
9292
}
9393

94-
/// When `true`, a PathSegment constraint that is the ONLY token in the
95-
/// query is demoted to fuzzy text. Grep modes enable this because the
96-
/// user is typing a search term (e.g. `/api/tests`), not scoping to a
97-
/// directory. File-search modes keep the default (`false`) so that
98-
/// `/src/` still filters by directory.
94+
/// If `true`, a PathSegment constraint that is the ONLY token in the
95+
/// query is demoted to fuzzy text to avoid over filtering
9996
fn treat_lone_path_as_text(&self) -> bool {
100-
false
97+
true
10198
}
10299

103100
/// Custom constraint parsers for picker-specific needs
@@ -146,10 +143,6 @@ impl ParserConfig for GrepConfig {
146143
false
147144
}
148145

149-
fn treat_lone_path_as_text(&self) -> bool {
150-
true
151-
}
152-
153146
/// Only recognise globs that are clearly directory/path oriented.
154147
///
155148
/// Characters like `?`, `[`, and bare `*` (without `/`) are extremely
@@ -222,10 +215,6 @@ impl ParserConfig for AiGrepConfig {
222215
false
223216
}
224217

225-
fn treat_lone_path_as_text(&self) -> bool {
226-
true
227-
}
228-
229218
fn is_glob_pattern(&self, token: &str) -> bool {
230219
// First check GrepConfig's strict rules (path globs, brace expansion)
231220
if GrepConfig.is_glob_pattern(token) {

crates/fff-query-parser/src/parser.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,40 +1037,6 @@ mod tests {
10371037
);
10381038
}
10391039

1040-
#[test]
1041-
fn test_file_search_leading_slash_path_alone_stays_path_segment() {
1042-
// FileSearchConfig (fuzzy file finder) should still treat a lone
1043-
// `/api/tests/` as a PathSegment constraint — the user is scoping
1044-
// the file list to that directory.
1045-
let parser = QueryParser::new(FileSearchConfig);
1046-
1047-
let result = parser.parse("/api/tests/");
1048-
assert_eq!(
1049-
result.constraints.len(),
1050-
1,
1051-
"FileSearchConfig: expected PathSegment constraint, got {:?}",
1052-
result.constraints
1053-
);
1054-
assert!(
1055-
matches!(result.constraints[0], Constraint::PathSegment("api/tests")),
1056-
"FileSearchConfig: expected PathSegment(\"api/tests\"), got {:?}",
1057-
result.constraints[0]
1058-
);
1059-
1060-
let result = parser.parse("/api/tests");
1061-
assert_eq!(
1062-
result.constraints.len(),
1063-
1,
1064-
"FileSearchConfig: expected PathSegment constraint, got {:?}",
1065-
result.constraints
1066-
);
1067-
assert!(
1068-
matches!(result.constraints[0], Constraint::PathSegment("api/tests")),
1069-
"FileSearchConfig: expected PathSegment(\"api/tests\"), got {:?}",
1070-
result.constraints[0]
1071-
);
1072-
}
1073-
10741040
#[test]
10751041
fn test_ai_grep_filename_with_extension_only_promotes_to_text() {
10761042
// Same case with an Extension constraint — no fuzzy text means the

doc/fff.nvim.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*fff.nvim.txt*
2-
For Neovim >= 0.10.0 Last change: 2026 April 26
2+
For Neovim >= 0.10.0 Last change: 2026 April 27
33

44
==============================================================================
55
Table of Contents *fff.nvim-table-of-contents*

0 commit comments

Comments
 (0)