Make row_count of toolbaritem dynamic (WIP).
Move result count to the left hand side.
This commit is contained in:
parent
8ca1e0b15b
commit
dff9bf7d7e
2 changed files with 20 additions and 7 deletions
|
@ -374,7 +374,9 @@ impl Item for ProjectSearchView {
|
|||
query_text.into()
|
||||
});
|
||||
Label::new(
|
||||
tab_name.unwrap_or("Project search".into()),
|
||||
tab_name
|
||||
.filter(|name| !name.is_empty())
|
||||
.unwrap_or("Project search".into()),
|
||||
tab_theme.label.clone(),
|
||||
)
|
||||
.aligned()
|
||||
|
@ -425,6 +427,7 @@ impl Item for ProjectSearchView {
|
|||
project: ModelHandle<Project>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Task<anyhow::Result<()>> {
|
||||
|
||||
self.results_editor
|
||||
.update(cx, |editor, cx| editor.reload(project, cx))
|
||||
}
|
||||
|
@ -825,6 +828,7 @@ impl ProjectSearchView {
|
|||
}
|
||||
|
||||
fn model_changed(&mut self, cx: &mut ViewContext<Self>) {
|
||||
|
||||
let match_ranges = self.model.read(cx).match_ranges.clone();
|
||||
if match_ranges.is_empty() {
|
||||
self.active_match_index = None;
|
||||
|
@ -1026,8 +1030,11 @@ impl ProjectSearchBar {
|
|||
if let Some(search_view) = self.active_project_search.as_ref() {
|
||||
search_view.update(cx, |search_view, cx| {
|
||||
search_view.filters_enabled = !search_view.filters_enabled;
|
||||
search_view.included_files_editor.update(cx, |_, cx| {cx.notify()});
|
||||
search_view.excluded_files_editor.update(cx, |_, cx| {cx.notify()});
|
||||
search_view.semantic = None;
|
||||
search_view.search(cx);
|
||||
cx.notify();
|
||||
});
|
||||
cx.notify();
|
||||
true
|
||||
|
@ -1325,12 +1332,12 @@ impl View for ProjectSearchBar {
|
|||
let semantic_index =
|
||||
SemanticIndex::enabled(cx).then(|| self.render_semantic_search_button(cx));
|
||||
Flex::row()
|
||||
.with_child(Flex::row().flex(1., true))
|
||||
.with_child(Flex::column().with_child(Flex::row().with_children(matches).aligned()
|
||||
.left()).flex(1., true))
|
||||
.with_child(
|
||||
Flex::column()
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_children(matches)
|
||||
.with_child(
|
||||
Flex::row()
|
||||
.with_child(query)
|
||||
|
@ -1413,8 +1420,14 @@ impl ToolbarItemView for ProjectSearchBar {
|
|||
}
|
||||
}
|
||||
|
||||
fn row_count(&self) -> usize {
|
||||
2
|
||||
fn row_count(&self, cx: &ViewContext<Self>) -> usize {
|
||||
self.active_project_search
|
||||
.as_ref()
|
||||
.map(|search| {
|
||||
let offset = search.read(cx).filters_enabled as usize;
|
||||
1 + offset
|
||||
})
|
||||
.unwrap_or_else(|| 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pub trait ToolbarItemView: View {
|
|||
/// Number of times toolbar's height will be repeated to get the effective height.
|
||||
/// Useful when multiple rows one under each other are needed.
|
||||
/// The rows have the same width and act as a whole when reacting to resizes and similar events.
|
||||
fn row_count(&self) -> usize {
|
||||
fn row_count(&self, _cx: &ViewContext<Self>) -> usize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for ViewHandle<T> {
|
|||
}
|
||||
|
||||
fn row_count(&self, cx: &WindowContext) -> usize {
|
||||
self.read(cx).row_count()
|
||||
self.read_with(cx, |this, cx| this.row_count(cx))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue