Fix project search filtering on projects with multiple worktrees (#9337)
Fixes #9285 Release Notes: - Fixed a bug that broke search filtering when searching a project with multiple worktrees ([#9285](https://github.com/zed-industries/zed/issues/9285)). --------- Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
7629c16162
commit
fab55486f5
4 changed files with 195 additions and 90 deletions
|
@ -23,7 +23,7 @@ use gpui::{
|
|||
use menu::Confirm;
|
||||
use project::{
|
||||
search::{SearchInputs, SearchQuery},
|
||||
Entry, Project,
|
||||
Project,
|
||||
};
|
||||
use semantic_index::{SemanticIndex, SemanticIndexStatus};
|
||||
|
||||
|
@ -34,7 +34,7 @@ use std::{
|
|||
any::{Any, TypeId},
|
||||
mem,
|
||||
ops::{Not, Range},
|
||||
path::PathBuf,
|
||||
path::{Path, PathBuf},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use theme::ThemeSettings;
|
||||
|
@ -990,13 +990,10 @@ impl ProjectSearchView {
|
|||
|
||||
pub fn new_search_in_directory(
|
||||
workspace: &mut Workspace,
|
||||
dir_entry: &Entry,
|
||||
dir_path: &Path,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
if !dir_entry.is_dir() {
|
||||
return;
|
||||
}
|
||||
let Some(filter_str) = dir_entry.path.to_str() else {
|
||||
let Some(filter_str) = dir_path.to_str() else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -2806,33 +2803,6 @@ pub mod tests {
|
|||
})
|
||||
.unwrap();
|
||||
|
||||
let one_file_entry = cx.update(|cx| {
|
||||
workspace
|
||||
.read(cx)
|
||||
.project()
|
||||
.read(cx)
|
||||
.entry_for_path(&(worktree_id, "a/one.rs").into(), cx)
|
||||
.expect("no entry for /a/one.rs file")
|
||||
});
|
||||
assert!(one_file_entry.is_file());
|
||||
window
|
||||
.update(cx, |workspace, cx| {
|
||||
ProjectSearchView::new_search_in_directory(workspace, &one_file_entry, cx)
|
||||
})
|
||||
.unwrap();
|
||||
let active_search_entry = cx.read(|cx| {
|
||||
workspace
|
||||
.read(cx)
|
||||
.active_pane()
|
||||
.read(cx)
|
||||
.active_item()
|
||||
.and_then(|item| item.downcast::<ProjectSearchView>())
|
||||
});
|
||||
assert!(
|
||||
active_search_entry.is_none(),
|
||||
"Expected no search panel to be active for file entry"
|
||||
);
|
||||
|
||||
let a_dir_entry = cx.update(|cx| {
|
||||
workspace
|
||||
.read(cx)
|
||||
|
@ -2844,7 +2814,7 @@ pub mod tests {
|
|||
assert!(a_dir_entry.is_dir());
|
||||
window
|
||||
.update(cx, |workspace, cx| {
|
||||
ProjectSearchView::new_search_in_directory(workspace, &a_dir_entry, cx)
|
||||
ProjectSearchView::new_search_in_directory(workspace, &a_dir_entry.path, cx)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue