Make production code compile again
This commit is contained in:
@@ -171,7 +171,7 @@ pub trait ItemHandle: 'static + fmt::Debug {
|
||||
fn subscribe_to_item_events(
|
||||
&self,
|
||||
cx: &mut WindowContext,
|
||||
handler: Box<dyn Fn(ItemEvent, &mut AppContext)>,
|
||||
handler: Box<dyn Fn(ItemEvent, &mut WindowContext)>,
|
||||
) -> gpui::Subscription;
|
||||
fn tab_description<'a>(&self, detail: usize, cx: &'a AppContext) -> Option<Cow<'a, str>>;
|
||||
fn tab_content(
|
||||
@@ -254,7 +254,7 @@ impl<T: Item> ItemHandle for ViewHandle<T> {
|
||||
fn subscribe_to_item_events(
|
||||
&self,
|
||||
cx: &mut WindowContext,
|
||||
handler: Box<dyn Fn(ItemEvent, &mut AppContext)>,
|
||||
handler: Box<dyn Fn(ItemEvent, &mut WindowContext)>,
|
||||
) -> gpui::Subscription {
|
||||
cx.subscribe(self, move |_, event, cx| {
|
||||
for item_event in T::to_item_events(event) {
|
||||
@@ -677,7 +677,7 @@ pub trait FollowableItem: Item {
|
||||
|
||||
pub trait FollowableItemHandle: ItemHandle {
|
||||
fn remote_id(&self, client: &Arc<Client>, cx: &AppContext) -> Option<ViewId>;
|
||||
fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut AppContext);
|
||||
fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut WindowContext);
|
||||
fn to_state_proto(&self, cx: &AppContext) -> Option<proto::view::Variant>;
|
||||
fn add_event_to_update_proto(
|
||||
&self,
|
||||
@@ -689,7 +689,7 @@ pub trait FollowableItemHandle: ItemHandle {
|
||||
&self,
|
||||
project: &ModelHandle<Project>,
|
||||
message: proto::update_view::Variant,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<()>>;
|
||||
fn should_unfollow_on_event(&self, event: &dyn Any, cx: &AppContext) -> bool;
|
||||
}
|
||||
@@ -704,7 +704,7 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
||||
})
|
||||
}
|
||||
|
||||
fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut AppContext) {
|
||||
fn set_leader_replica_id(&self, leader_replica_id: Option<u16>, cx: &mut WindowContext) {
|
||||
self.update(cx, |this, cx| {
|
||||
this.set_leader_replica_id(leader_replica_id, cx)
|
||||
})
|
||||
@@ -731,7 +731,7 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
||||
&self,
|
||||
project: &ModelHandle<Project>,
|
||||
message: proto::update_view::Variant,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<()>> {
|
||||
self.update(cx, |this, cx| this.apply_update_proto(project, message, cx))
|
||||
}
|
||||
|
||||
@@ -1890,15 +1890,15 @@ fn render_tab_bar_button<A: Action + Clone>(
|
||||
}
|
||||
|
||||
impl ItemNavHistory {
|
||||
pub fn push<D: 'static + Any>(&self, data: Option<D>, cx: &mut AppContext) {
|
||||
pub fn push<D: 'static + Any>(&self, data: Option<D>, cx: &mut WindowContext) {
|
||||
self.history.borrow_mut().push(data, self.item.clone(), cx);
|
||||
}
|
||||
|
||||
pub fn pop_backward(&self, cx: &mut AppContext) -> Option<NavigationEntry> {
|
||||
pub fn pop_backward(&self, cx: &mut WindowContext) -> Option<NavigationEntry> {
|
||||
self.history.borrow_mut().pop(NavigationMode::GoingBack, cx)
|
||||
}
|
||||
|
||||
pub fn pop_forward(&self, cx: &mut AppContext) -> Option<NavigationEntry> {
|
||||
pub fn pop_forward(&self, cx: &mut WindowContext) -> Option<NavigationEntry> {
|
||||
self.history
|
||||
.borrow_mut()
|
||||
.pop(NavigationMode::GoingForward, cx)
|
||||
@@ -1918,7 +1918,7 @@ impl NavHistory {
|
||||
self.mode = NavigationMode::Normal;
|
||||
}
|
||||
|
||||
fn pop(&mut self, mode: NavigationMode, cx: &mut AppContext) -> Option<NavigationEntry> {
|
||||
fn pop(&mut self, mode: NavigationMode, cx: &mut WindowContext) -> Option<NavigationEntry> {
|
||||
let entry = match mode {
|
||||
NavigationMode::Normal | NavigationMode::Disabled | NavigationMode::ClosingItem => {
|
||||
return None
|
||||
@@ -1938,7 +1938,7 @@ impl NavHistory {
|
||||
&mut self,
|
||||
data: Option<D>,
|
||||
item: Rc<dyn WeakItemHandle>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) {
|
||||
match self.mode {
|
||||
NavigationMode::Disabled => {}
|
||||
@@ -1983,7 +1983,7 @@ impl NavHistory {
|
||||
self.did_update(cx);
|
||||
}
|
||||
|
||||
fn did_update(&self, cx: &mut AppContext) {
|
||||
fn did_update(&self, cx: &mut WindowContext) {
|
||||
if let Some(pane) = self.pane.upgrade(cx) {
|
||||
cx.defer(move |cx| pane.update(cx, |pane, cx| pane.history_updated(cx)));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::any::Any;
|
||||
|
||||
use gpui::{
|
||||
AnyViewHandle, AnyWeakViewHandle, AppContext, Subscription, Task, ViewContext, ViewHandle,
|
||||
WeakViewHandle,
|
||||
WeakViewHandle, WindowContext,
|
||||
};
|
||||
use project::search::SearchQuery;
|
||||
|
||||
@@ -90,29 +90,34 @@ pub trait SearchableItemHandle: ItemHandle {
|
||||
fn supported_options(&self) -> SearchOptions;
|
||||
fn subscribe_to_search_events(
|
||||
&self,
|
||||
cx: &mut AppContext,
|
||||
handler: Box<dyn Fn(SearchEvent, &mut AppContext)>,
|
||||
cx: &mut WindowContext,
|
||||
handler: Box<dyn Fn(SearchEvent, &mut WindowContext)>,
|
||||
) -> Subscription;
|
||||
fn clear_matches(&self, cx: &mut AppContext);
|
||||
fn update_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut AppContext);
|
||||
fn query_suggestion(&self, cx: &mut AppContext) -> String;
|
||||
fn activate_match(&self, index: usize, matches: &Vec<Box<dyn Any + Send>>, cx: &mut AppContext);
|
||||
fn clear_matches(&self, cx: &mut WindowContext);
|
||||
fn update_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut WindowContext);
|
||||
fn query_suggestion(&self, cx: &mut WindowContext) -> String;
|
||||
fn activate_match(
|
||||
&self,
|
||||
index: usize,
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
cx: &mut WindowContext,
|
||||
);
|
||||
fn match_index_for_direction(
|
||||
&self,
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
current_index: usize,
|
||||
direction: Direction,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> usize;
|
||||
fn find_matches(
|
||||
&self,
|
||||
query: SearchQuery,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Vec<Box<dyn Any + Send>>>;
|
||||
fn active_match_index(
|
||||
&self,
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Option<usize>;
|
||||
}
|
||||
|
||||
@@ -131,8 +136,8 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> {
|
||||
|
||||
fn subscribe_to_search_events(
|
||||
&self,
|
||||
cx: &mut AppContext,
|
||||
handler: Box<dyn Fn(SearchEvent, &mut AppContext)>,
|
||||
cx: &mut WindowContext,
|
||||
handler: Box<dyn Fn(SearchEvent, &mut WindowContext)>,
|
||||
) -> Subscription {
|
||||
cx.subscribe(self, move |_, event, cx| {
|
||||
if let Some(search_event) = T::to_search_event(event) {
|
||||
@@ -141,21 +146,21 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> {
|
||||
})
|
||||
}
|
||||
|
||||
fn clear_matches(&self, cx: &mut AppContext) {
|
||||
fn clear_matches(&self, cx: &mut WindowContext) {
|
||||
self.update(cx, |this, cx| this.clear_matches(cx));
|
||||
}
|
||||
fn update_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut AppContext) {
|
||||
fn update_matches(&self, matches: &Vec<Box<dyn Any + Send>>, cx: &mut WindowContext) {
|
||||
let matches = downcast_matches(matches);
|
||||
self.update(cx, |this, cx| this.update_matches(matches, cx));
|
||||
}
|
||||
fn query_suggestion(&self, cx: &mut AppContext) -> String {
|
||||
fn query_suggestion(&self, cx: &mut WindowContext) -> String {
|
||||
self.update(cx, |this, cx| this.query_suggestion(cx))
|
||||
}
|
||||
fn activate_match(
|
||||
&self,
|
||||
index: usize,
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) {
|
||||
let matches = downcast_matches(matches);
|
||||
self.update(cx, |this, cx| this.activate_match(index, matches, cx));
|
||||
@@ -165,7 +170,7 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> {
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
current_index: usize,
|
||||
direction: Direction,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> usize {
|
||||
let matches = downcast_matches(matches);
|
||||
self.update(cx, |this, cx| {
|
||||
@@ -175,7 +180,7 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> {
|
||||
fn find_matches(
|
||||
&self,
|
||||
query: SearchQuery,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Vec<Box<dyn Any + Send>>> {
|
||||
let matches = self.update(cx, |this, cx| this.find_matches(query, cx));
|
||||
cx.foreground().spawn(async {
|
||||
@@ -189,7 +194,7 @@ impl<T: SearchableItem> SearchableItemHandle for ViewHandle<T> {
|
||||
fn active_match_index(
|
||||
&self,
|
||||
matches: &Vec<Box<dyn Any + Send>>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> Option<usize> {
|
||||
let matches = downcast_matches(matches);
|
||||
self.update(cx, |this, cx| this.active_match_index(matches, cx))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{ItemHandle, Pane};
|
||||
use gpui::{
|
||||
elements::*, platform::CursorStyle, platform::MouseButton, Action, AnyViewHandle, AppContext,
|
||||
Element, Entity, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
Element, Entity, View, ViewContext, ViewHandle, WeakViewHandle, WindowContext,
|
||||
};
|
||||
use settings::Settings;
|
||||
|
||||
@@ -21,7 +21,7 @@ pub trait ToolbarItemView: View {
|
||||
current_location
|
||||
}
|
||||
|
||||
fn pane_focus_update(&mut self, _pane_focused: bool, _cx: &mut AppContext) {}
|
||||
fn pane_focus_update(&mut self, _pane_focused: bool, _cx: &mut ViewContext<Self>) {}
|
||||
}
|
||||
|
||||
trait ToolbarItemViewHandle {
|
||||
@@ -30,9 +30,9 @@ trait ToolbarItemViewHandle {
|
||||
fn set_active_pane_item(
|
||||
&self,
|
||||
active_pane_item: Option<&dyn ItemHandle>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> ToolbarItemLocation;
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut AppContext);
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut WindowContext);
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
@@ -263,7 +263,7 @@ impl Toolbar {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut AppContext) {
|
||||
pub fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut ViewContext<Self>) {
|
||||
for (toolbar_item, _) in self.items.iter_mut() {
|
||||
toolbar_item.pane_focus_update(pane_focused, cx);
|
||||
}
|
||||
@@ -292,14 +292,14 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for ViewHandle<T> {
|
||||
fn set_active_pane_item(
|
||||
&self,
|
||||
active_pane_item: Option<&dyn ItemHandle>,
|
||||
cx: &mut AppContext,
|
||||
cx: &mut WindowContext,
|
||||
) -> ToolbarItemLocation {
|
||||
self.update(cx, |this, cx| {
|
||||
this.set_active_pane_item(active_pane_item, cx)
|
||||
})
|
||||
}
|
||||
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut AppContext) {
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, cx: &mut WindowContext) {
|
||||
self.update(cx, |this, cx| this.pane_focus_update(pane_focused, cx));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,20 +397,18 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
.await
|
||||
.context("Failed to create CLI symlink");
|
||||
|
||||
cx.update(|cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
if matches!(err, Err(_)) {
|
||||
err.notify_err(workspace, cx);
|
||||
} else {
|
||||
workspace.show_notification(1, cx, |cx| {
|
||||
cx.add_view(|_| {
|
||||
MessageNotification::new_message(
|
||||
"Successfully installed the `zed` binary",
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
if matches!(err, Err(_)) {
|
||||
err.notify_err(workspace, cx);
|
||||
} else {
|
||||
workspace.show_notification(1, cx, |cx| {
|
||||
cx.add_view(|_| {
|
||||
MessageNotification::new_message(
|
||||
"Successfully installed the `zed` binary",
|
||||
)
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
.detach();
|
||||
@@ -724,11 +722,9 @@ impl Workspace {
|
||||
Stream::map(current_user, drop).merge(Stream::map(connection_status, drop));
|
||||
|
||||
while stream.recv().await.is_some() {
|
||||
cx.update(|cx| {
|
||||
if let Some(this) = this.upgrade(cx) {
|
||||
this.update(cx, |_, cx| cx.notify());
|
||||
}
|
||||
})
|
||||
if let Some(this) = this.upgrade(&cx) {
|
||||
this.update(&mut cx, |_, cx| cx.notify());
|
||||
}
|
||||
}
|
||||
});
|
||||
let handle = cx.handle();
|
||||
|
||||
Reference in New Issue
Block a user