Allow buffer search in project search (#23819)
Closes #13437 Closes #19993 Release Notes: - Allow searching within the results of a project search - vim: Fix `/`/`?`, `n`/`N`, `gn`/`gN`,`*`/`#` in project search results --------- Co-authored-by: Nico <nico.lehmann@gmail.com>
This commit is contained in:
parent
e1af35aa15
commit
f2b3f3a9ab
10 changed files with 191 additions and 105 deletions
|
@ -42,18 +42,20 @@ pub struct SearchOptions {
|
|||
/// Specifies whether the supports search & replace.
|
||||
pub replacement: bool,
|
||||
pub selection: bool,
|
||||
pub find_in_results: bool,
|
||||
}
|
||||
|
||||
pub trait SearchableItem: Item + EventEmitter<SearchEvent> {
|
||||
type Match: Any + Sync + Send + Clone;
|
||||
|
||||
fn supported_options() -> SearchOptions {
|
||||
fn supported_options(&self) -> SearchOptions {
|
||||
SearchOptions {
|
||||
case: true,
|
||||
word: true,
|
||||
regex: true,
|
||||
replacement: true,
|
||||
selection: true,
|
||||
find_in_results: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +68,7 @@ pub trait SearchableItem: Item + EventEmitter<SearchEvent> {
|
|||
}
|
||||
|
||||
fn has_filtered_search_ranges(&mut self) -> bool {
|
||||
Self::supported_options().selection
|
||||
self.supported_options().selection
|
||||
}
|
||||
|
||||
fn toggle_filtered_search_ranges(
|
||||
|
@ -157,7 +159,7 @@ pub trait SearchableItem: Item + EventEmitter<SearchEvent> {
|
|||
pub trait SearchableItemHandle: ItemHandle {
|
||||
fn downgrade(&self) -> Box<dyn WeakSearchableItemHandle>;
|
||||
fn boxed_clone(&self) -> Box<dyn SearchableItemHandle>;
|
||||
fn supported_options(&self) -> SearchOptions;
|
||||
fn supported_options(&self, cx: &App) -> SearchOptions;
|
||||
fn subscribe_to_search_events(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
|
@ -224,8 +226,8 @@ impl<T: SearchableItem> SearchableItemHandle for Entity<T> {
|
|||
Box::new(self.clone())
|
||||
}
|
||||
|
||||
fn supported_options(&self) -> SearchOptions {
|
||||
T::supported_options()
|
||||
fn supported_options(&self, cx: &App) -> SearchOptions {
|
||||
self.read(cx).supported_options()
|
||||
}
|
||||
|
||||
fn subscribe_to_search_events(
|
||||
|
|
|
@ -82,7 +82,7 @@ impl Toolbar {
|
|||
}
|
||||
|
||||
fn secondary_items(&self) -> impl Iterator<Item = &dyn ToolbarItemViewHandle> {
|
||||
self.items.iter().filter_map(|(item, location)| {
|
||||
self.items.iter().rev().filter_map(|(item, location)| {
|
||||
if *location == ToolbarItemLocation::Secondary {
|
||||
Some(item.as_ref())
|
||||
} else {
|
||||
|
@ -98,7 +98,7 @@ impl Render for Toolbar {
|
|||
return div();
|
||||
}
|
||||
|
||||
let secondary_item = self.secondary_items().next().map(|item| item.to_any());
|
||||
let secondary_items = self.secondary_items().map(|item| item.to_any());
|
||||
|
||||
let has_left_items = self.left_items().count() > 0;
|
||||
let has_right_items = self.right_items().count() > 0;
|
||||
|
@ -145,7 +145,7 @@ impl Render for Toolbar {
|
|||
}),
|
||||
)
|
||||
})
|
||||
.children(secondary_item)
|
||||
.children(secondary_items)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue