Hide breadcrumbs when project search has no results

This commit is contained in:
Antonio Scandurra 2022-04-01 10:00:21 +02:00
parent 9f939bd007
commit 7f9ff47089
4 changed files with 61 additions and 14 deletions

View file

@ -2,8 +2,9 @@ use crate::{active_match_index, match_index_for_direction, Direction, SearchOpti
use collections::HashMap;
use editor::{display_map::ToDisplayPoint, Anchor, Autoscroll, Bias, Editor};
use gpui::{
action, elements::*, keymap::Binding, platform::CursorStyle, Entity, MutableAppContext,
RenderContext, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
action, elements::*, keymap::Binding, platform::CursorStyle, AppContext, Entity,
MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
WeakViewHandle,
};
use language::OffsetRangeExt;
use project::search::SearchQuery;
@ -164,7 +165,12 @@ impl ToolbarItemView for BufferSearchBar {
ToolbarItemLocation::Hidden
}
fn location_for_event(&self, _: &Self::Event, _: ToolbarItemLocation) -> ToolbarItemLocation {
fn location_for_event(
&self,
_: &Self::Event,
_: ToolbarItemLocation,
_: &AppContext,
) -> ToolbarItemLocation {
if self.active_editor.is_some() && !self.dismissed {
ToolbarItemLocation::Secondary
} else {

View file

@ -487,6 +487,10 @@ impl ProjectSearchView {
cx.notify();
}
}
pub fn has_matches(&self) -> bool {
self.active_match_index.is_some()
}
}
impl ProjectSearchBar {