Skip to content
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

Replace path pattern with include and exclude fields #78

Merged
merged 8 commits into from
Mar 7, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update docs and tests
thomasschafer committed Mar 6, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c9c7b0a6754a1a1aad7f76a00d24bc98cf9ece6f
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,9 @@ When on the search screen the following fields are available:
- **Match whole word**: If enabled, only match when the search string forms the entire word and not a substring in a larger word. For instance, if the search string is "foo", "foo bar" would be matched but not "foobar".
- **Match case**: If enabled, match the case of the search string exactly, e.g. a search string of `Bar` would match `foo Bar baz` but not `foo bar baz`.
- **Files to include**: Glob pattern that file paths must match: for instance, `*.rs` matches all files with the `.rs` extension.
- **Files to exclude**: Glob pattern that file paths must not match: for instance, `env/` ignores all files in the `env` directory. This field takes precedence over the pattern in the "Files to include" field.
- **Files to exclude**: Glob pattern that file paths must not match: for instance, `env/**` ignores all files in the `env` directory. This field takes precedence over the pattern in the "Files to include" field.

Note that the glob matching library used in Scooter comes from the author of the brilliant [ripgrep](https://github.com/BurntSushi/ripgrep), and matches the behaviour there: for instance, if you wanted to include only files in the directory `dir1`, you'd need to add `dir1/**` in the "Files to include" field - `dir1` alone would not work.

## Installation

46 changes: 41 additions & 5 deletions tests/app.rs
Original file line number Diff line number Diff line change
@@ -875,7 +875,16 @@ test_with_both_regex_modes!(
"something testing",
},
"dir3/file4.txt" => {
"some testing text",
"some testing text from dir3/file4.txt, blah",
},
"dir3/subdir1/file5.txt" => {
"some testing text from dir3/subdir1/file5.txt, blah",
},
"dir4/subdir2/file6.txt" => {
"some testing text from dir4/subdir2/file6.txt, blah",
},
"dir4/subdir3/file7.txt" => {
"some testing text from dir4/subdir3/file7.txt, blah",
},
);

@@ -885,8 +894,7 @@ test_with_both_regex_modes!(
fixed_strings: false,
whole_word: false,
match_case: true,
// TODO: why do we need the /* ???
include_files: "dir2/*, dir3",
include_files: "dir2/*, dir3/**, */subdir3/*",
exclude_files: "",
})
.with_advanced_regex(advanced_regex);
@@ -899,6 +907,9 @@ test_with_both_regex_modes!(
(&Path::new("dir2").join("file2.txt"), 1),
(&Path::new("dir2").join("file3.txt"), 1),
(&Path::new("dir3").join("file4.txt"), 1),
(&Path::new("dir3").join("subdir1").join("file5.txt"), 1),
(&Path::new("dir4").join("subdir2").join("file6.txt"), 0),
(&Path::new("dir4").join("subdir3").join("file7.txt"), 1),
],
)
.await;
@@ -921,14 +932,22 @@ test_with_both_regex_modes!(
"something f",
},
"dir3/file4.txt" => {
"some f text",
"some f text from dir3/file4.txt, blah",
},
"dir3/subdir1/file5.txt" => {
"some f text from dir3/subdir1/file5.txt, blah",
},
"dir4/subdir2/file6.txt" => {
"some testing text from dir4/subdir2/file6.txt, blah",
},
"dir4/subdir3/file7.txt" => {
"some f text from dir4/subdir3/file7.txt, blah",
},
);
Ok(())
}
);

// TODO
test_with_both_regex_modes!(
test_update_search_results_exclude_dir,
|advanced_regex: bool| async move {
@@ -1133,6 +1152,11 @@ test_with_both_regex_modes!(
r#" "testing2""#,
"}",
},
"dir1/subdir1/subdir2/file3.rs" => {
"func testing3() {",
r#" "testing3""#,
"}",
},
"dir2/file1.txt" => {
"This is a test file",
"It contains some test content",
@@ -1172,6 +1196,13 @@ test_with_both_regex_modes!(
(&Path::new("dir1").join("file1.txt"), 1),
(&Path::new("dir1").join("file1.rs"), 2),
(&Path::new("dir1").join("file2.rs"), 0),
(
&Path::new("dir1")
.join("subdir1")
.join("subdir2")
.join("file3.rs"),
2,
),
(&Path::new("dir2").join("file1.txt"), 0),
(&Path::new("dir2").join("file2.rs"), 0),
(&Path::new("dir2").join("file3.rs"), 1),
@@ -1197,6 +1228,11 @@ test_with_both_regex_modes!(
r#" "testing2""#,
"}",
},
"dir1/subdir1/subdir2/file3.rs" => {
"func REPL3() {",
r#" "REPL3""#,
"}",
},
"dir2/file1.txt" => {
"This is a test file",
"It contains some test content",