Search in selections (#10831)
Release Notes: - Adding [#8617 ](https://github.com/zed-industries/zed/issues/8617) --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
428c143fbb
commit
c7c19609b3
13 changed files with 818 additions and 69 deletions
|
@ -39,8 +39,9 @@ pub struct SearchOptions {
|
|||
pub case: bool,
|
||||
pub word: bool,
|
||||
pub regex: bool,
|
||||
/// Specifies whether the item supports search & replace.
|
||||
/// Specifies whether the supports search & replace.
|
||||
pub replacement: bool,
|
||||
pub selection: bool,
|
||||
}
|
||||
|
||||
pub trait SearchableItem: Item + EventEmitter<SearchEvent> {
|
||||
|
@ -52,15 +53,18 @@ pub trait SearchableItem: Item + EventEmitter<SearchEvent> {
|
|||
word: true,
|
||||
regex: true,
|
||||
replacement: true,
|
||||
selection: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn search_bar_visibility_changed(&mut self, _visible: bool, _cx: &mut ViewContext<Self>) {}
|
||||
|
||||
fn has_filtered_search_ranges(&mut self) -> bool {
|
||||
false
|
||||
Self::supported_options().selection
|
||||
}
|
||||
|
||||
fn toggle_filtered_search_ranges(&mut self, _enabled: bool, _cx: &mut ViewContext<Self>) {}
|
||||
|
||||
fn clear_matches(&mut self, cx: &mut ViewContext<Self>);
|
||||
fn update_matches(&mut self, matches: &[Self::Match], cx: &mut ViewContext<Self>);
|
||||
fn query_suggestion(&mut self, cx: &mut ViewContext<Self>) -> String;
|
||||
|
@ -138,6 +142,8 @@ pub trait SearchableItemHandle: ItemHandle {
|
|||
cx: &mut WindowContext,
|
||||
) -> Option<usize>;
|
||||
fn search_bar_visibility_changed(&self, visible: bool, cx: &mut WindowContext);
|
||||
|
||||
fn toggle_filtered_search_ranges(&mut self, enabled: bool, cx: &mut WindowContext);
|
||||
}
|
||||
|
||||
impl<T: SearchableItem> SearchableItemHandle for View<T> {
|
||||
|
@ -240,6 +246,12 @@ impl<T: SearchableItem> SearchableItemHandle for View<T> {
|
|||
this.search_bar_visibility_changed(visible, cx)
|
||||
});
|
||||
}
|
||||
|
||||
fn toggle_filtered_search_ranges(&mut self, enabled: bool, cx: &mut WindowContext) {
|
||||
self.update(cx, |this, cx| {
|
||||
this.toggle_filtered_search_ranges(enabled, cx)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<dyn SearchableItemHandle>> for AnyView {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue