@@ -468,6 +468,12 @@ impl Focusable for BufferSearchBar {
}
impl ToolbarItemView for BufferSearchBar {
+ fn contribute_context(&self, context: &mut KeyContext, _cx: &App) {
+ if !self.dismissed {
+ context.add("buffer_search_deployed");
+ }
+ }
+
fn set_active_pane_item(
&mut self,
item: Option<&dyn ItemHandle>,
@@ -3702,6 +3702,10 @@ impl Render for Pane {
key_context.add("EmptyPane");
}
+ self.toolbar
+ .read(cx)
+ .contribute_context(&mut key_context, cx);
+
let should_display_tab_bar = self.should_display_tab_bar.clone();
let display_tab_bar = should_display_tab_bar(window, cx);
let Some(project) = self.project.upgrade() else {
@@ -1,7 +1,7 @@
use crate::ItemHandle;
use gpui::{
- AnyView, App, Context, Entity, EntityId, EventEmitter, ParentElement as _, Render, Styled,
- Window,
+ AnyView, App, Context, Entity, EntityId, EventEmitter, KeyContext, ParentElement as _, Render,
+ Styled, Window,
};
use ui::prelude::*;
use ui::{h_flex, v_flex};
@@ -25,6 +25,8 @@ pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
_cx: &mut Context<Self>,
) {
}
+
+ fn contribute_context(&self, _context: &mut KeyContext, _cx: &App) {}
}
trait ToolbarItemViewHandle: Send {
@@ -37,6 +39,7 @@ trait ToolbarItemViewHandle: Send {
cx: &mut App,
) -> ToolbarItemLocation;
fn focus_changed(&mut self, pane_focused: bool, window: &mut Window, cx: &mut App);
+ fn contribute_context(&self, context: &mut KeyContext, cx: &App);
}
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -236,6 +239,14 @@ impl Toolbar {
pub fn hidden(&self) -> bool {
self.hidden
}
+
+ pub fn contribute_context(&self, context: &mut KeyContext, cx: &App) {
+ for (item, location) in &self.items {
+ if *location != ToolbarItemLocation::Hidden {
+ item.contribute_context(context, cx);
+ }
+ }
+ }
}
impl<T: ToolbarItemView> ToolbarItemViewHandle for Entity<T> {
@@ -264,4 +275,8 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for Entity<T> {
cx.notify();
});
}
+
+ fn contribute_context(&self, context: &mut KeyContext, cx: &App) {
+ self.read(cx).contribute_context(context, cx)
+ }
}