Be more lenient when looking up gitignored files in file finder (#31457)
The lookup was disabled due to concerns of being forced to traverse many gitignored file entries. Since Zed does not index these eagerly, but only contents of the directories that are parent to the gitignored file entries, it might be not that bad — let's see how much improvement it provides. Closes https://github.com/zed-industries/zed/issues/31016 Release Notes: - Improved file finder to include indexed gitignored files in its search results
This commit is contained in:
parent
534bb0620d
commit
5b320d6714
2 changed files with 79 additions and 10 deletions
|
@ -779,9 +779,7 @@ impl FileFinderDelegate {
|
|||
let worktree = worktree.read(cx);
|
||||
PathMatchCandidateSet {
|
||||
snapshot: worktree.snapshot(),
|
||||
include_ignored: worktree
|
||||
.root_entry()
|
||||
.map_or(false, |entry| entry.is_ignored),
|
||||
include_ignored: true,
|
||||
include_root_name,
|
||||
candidates: project::Candidates::Files,
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use menu::{Confirm, SelectNext, SelectPrevious};
|
|||
use project::{FS_WATCH_LATENCY, RemoveOptions};
|
||||
use serde_json::json;
|
||||
use util::path;
|
||||
use workspace::{AppState, OpenOptions, ToggleFileFinder, Workspace};
|
||||
use workspace::{AppState, CloseActiveItem, OpenOptions, ToggleFileFinder, Workspace};
|
||||
|
||||
#[ctor::ctor]
|
||||
fn init_logger() {
|
||||
|
@ -615,9 +615,13 @@ async fn test_ignored_root(cx: &mut TestAppContext) {
|
|||
"hiccup": "",
|
||||
},
|
||||
"tracked-root": {
|
||||
".gitignore": "height",
|
||||
".gitignore": "height*",
|
||||
"happiness": "",
|
||||
"height": "",
|
||||
"heights": {
|
||||
"height_1": "",
|
||||
"height_2": "",
|
||||
},
|
||||
"hi": "",
|
||||
"hiccup": "",
|
||||
},
|
||||
|
@ -628,14 +632,13 @@ async fn test_ignored_root(cx: &mut TestAppContext) {
|
|||
let project = Project::test(
|
||||
app_state.fs.clone(),
|
||||
[
|
||||
"/ancestor/tracked-root".as_ref(),
|
||||
"/ancestor/ignored-root".as_ref(),
|
||||
Path::new(path!("/ancestor/tracked-root")),
|
||||
Path::new(path!("/ancestor/ignored-root")),
|
||||
],
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
|
||||
let (picker, _, cx) = build_find_picker(project, cx);
|
||||
let (picker, workspace, cx) = build_find_picker(project, cx);
|
||||
|
||||
picker
|
||||
.update_in(cx, |picker, window, cx| {
|
||||
|
@ -644,7 +647,75 @@ async fn test_ignored_root(cx: &mut TestAppContext) {
|
|||
.spawn_search(test_path_position("hi"), window, cx)
|
||||
})
|
||||
.await;
|
||||
picker.update(cx, |picker, _| assert_eq!(picker.delegate.matches.len(), 7));
|
||||
picker.update(cx, |picker, _| {
|
||||
let matches = collect_search_matches(picker);
|
||||
assert_eq!(matches.history.len(), 0);
|
||||
assert_eq!(
|
||||
matches.search,
|
||||
vec![
|
||||
PathBuf::from("ignored-root/hi"),
|
||||
PathBuf::from("tracked-root/hi"),
|
||||
PathBuf::from("ignored-root/hiccup"),
|
||||
PathBuf::from("tracked-root/hiccup"),
|
||||
PathBuf::from("ignored-root/height"),
|
||||
PathBuf::from("tracked-root/height"),
|
||||
PathBuf::from("ignored-root/happiness"),
|
||||
PathBuf::from("tracked-root/happiness"),
|
||||
],
|
||||
"All ignored files that were indexed are found"
|
||||
);
|
||||
});
|
||||
|
||||
workspace
|
||||
.update_in(cx, |workspace, window, cx| {
|
||||
workspace.open_abs_path(
|
||||
PathBuf::from(path!("/ancestor/tracked-root/heights/height_1")),
|
||||
OpenOptions {
|
||||
visible: Some(OpenVisible::None),
|
||||
..OpenOptions::default()
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
workspace
|
||||
.update_in(cx, |workspace, window, cx| {
|
||||
workspace.active_pane().update(cx, |pane, cx| {
|
||||
pane.close_active_item(&CloseActiveItem::default(), window, cx)
|
||||
.unwrap()
|
||||
})
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
picker
|
||||
.update_in(cx, |picker, window, cx| {
|
||||
picker
|
||||
.delegate
|
||||
.spawn_search(test_path_position("hi"), window, cx)
|
||||
})
|
||||
.await;
|
||||
picker.update(cx, |picker, _| {
|
||||
let matches = collect_search_matches(picker);
|
||||
assert_eq!(matches.history.len(), 0);
|
||||
assert_eq!(
|
||||
matches.search,
|
||||
vec![
|
||||
PathBuf::from("ignored-root/hi"),
|
||||
PathBuf::from("tracked-root/hi"),
|
||||
PathBuf::from("ignored-root/hiccup"),
|
||||
PathBuf::from("tracked-root/hiccup"),
|
||||
PathBuf::from("ignored-root/height"),
|
||||
PathBuf::from("tracked-root/height"),
|
||||
PathBuf::from("tracked-root/heights/height_1"),
|
||||
PathBuf::from("tracked-root/heights/height_2"),
|
||||
PathBuf::from("ignored-root/happiness"),
|
||||
PathBuf::from("tracked-root/happiness"),
|
||||
],
|
||||
"All ignored files that were indexed are found"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue