Unified · Split
| @@ -848,7 +848,7 @@ impl Workspace { · 847 unmodified lines | |||
| 848 | self.window_edited | 848 | self.window_edited |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>) { | 851 | pub fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut WindowContext) { |
| 852 | let dock = match panel.position(cx) { | 852 | let dock = match panel.position(cx) { |
| 853 | DockPosition::Left => &self.left_dock, | 853 | DockPosition::Left => &self.left_dock, |
| 854 | DockPosition::Bottom => &self.bottom_dock, | 854 | DockPosition::Bottom => &self.bottom_dock, |
| @@ -1488,14 +1488,14 @@ impl Workspace { · 633 unmodified lines | |||
| 1488 | item.to_any().downcast::<I>().ok() | 1488 | item.to_any().downcast::<I>().ok() |
| 1489 | } | 1489 | } |
| 1490 | 1490 | ||
| 1491 | fn active_project_path(&self, cx: &ViewContext<Self>) -> Option<ProjectPath> { | 1491 | fn active_project_path(&self, cx: &AppContext) -> Option<ProjectPath> { |
| 1492 | self.active_item(cx).and_then(|item| item.project_path(cx)) | 1492 | self.active_item(cx).and_then(|item| item.project_path(cx)) |
| 1493 | } | 1493 | } |
| 1494 | 1494 | ||
| 1495 | pub fn save_active_item( | 1495 | pub fn save_active_item( |
| 1496 | &mut self, | 1496 | &mut self, |
| 1497 | save_intent: SaveIntent, | 1497 | save_intent: SaveIntent, |
| 1498 | cx: &mut ViewContext<Self>, | 1498 | cx: &mut WindowContext, |
| 1499 | ) -> Task<Result<()>> { | 1499 | ) -> Task<Result<()>> { |
| 1500 | let project = self.project.clone(); | 1500 | let project = self.project.clone(); |
| 1501 | let pane = self.active_pane(); | 1501 | let pane = self.active_pane(); |
| @@ -1503,7 +1503,7 @@ impl Workspace { · 1 unmodified line | |||
| 1503 | let item = pane.read(cx).active_item(); | 1503 | let item = pane.read(cx).active_item(); |
| 1504 | let pane = pane.downgrade(); | 1504 | let pane = pane.downgrade(); |
| 1505 | 1505 | ||
| 1506 | cx.spawn(|_, mut cx| async move { | 1506 | cx.spawn(|mut cx| async move { |
| 1507 | if let Some(item) = item { | 1507 | if let Some(item) = item { |
| 1508 | Pane::save_item(project, &pane, item_ix, item.as_ref(), save_intent, &mut cx) | 1508 | Pane::save_item(project, &pane, item_ix, item.as_ref(), save_intent, &mut cx) |
| 1509 | .await | 1509 | .await |
| @@ -1764,7 +1764,7 @@ impl Workspace { · 254 unmodified lines | |||
| 1764 | } | 1764 | } |
| 1765 | } | 1765 | } |
| 1766 | 1766 | ||
| 1767 | pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) { | 1767 | pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut WindowContext) { |
| 1768 | if let Some(text) = item.telemetry_event_text(cx) { | 1768 | if let Some(text) = item.telemetry_event_text(cx) { |
| 1769 | self.client() | 1769 | self.client() |
| 1770 | .telemetry() | 1770 | .telemetry() |
| @@ -1846,7 +1846,7 @@ impl Workspace { · 75 unmodified lines | |||
| 1846 | path: impl Into<ProjectPath>, | 1846 | path: impl Into<ProjectPath>, |
| 1847 | pane: Option<WeakView<Pane>>, | 1847 | pane: Option<WeakView<Pane>>, |
| 1848 | focus_item: bool, | 1848 | focus_item: bool, |
| 1849 | cx: &mut ViewContext<Self>, | 1849 | cx: &mut WindowContext, |
| 1850 | ) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> { | 1850 | ) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> { |
| 1851 | let pane = pane.unwrap_or_else(|| { | 1851 | let pane = pane.unwrap_or_else(|| { |
| 1852 | self.last_active_center_pane.clone().unwrap_or_else(|| { | 1852 | self.last_active_center_pane.clone().unwrap_or_else(|| { |
| @@ -1858,7 +1858,7 @@ impl Workspace { · 5 unmodified lines | |||
| 1858 | }); | 1858 | }); |
| 1859 | 1859 | ||
| 1860 | let task = self.load_path(path.into(), cx); | 1860 | let task = self.load_path(path.into(), cx); |
| 1861 | cx.spawn(move |_, mut cx| async move { | 1861 | cx.spawn(move |mut cx| async move { |
| 1862 | let (project_entry_id, build_item) = task.await?; | 1862 | let (project_entry_id, build_item) = task.await?; |
| 1863 | pane.update(&mut cx, |pane, cx| { | 1863 | pane.update(&mut cx, |pane, cx| { |
| 1864 | pane.open_item(project_entry_id, focus_item, cx, build_item) | 1864 | pane.open_item(project_entry_id, focus_item, cx, build_item) |
| @@ -1901,7 +1901,7 @@ impl Workspace { · 36 unmodified lines | |||
| 1901 | fn load_path( | 1901 | fn load_path( |
| 1902 | &mut self, | 1902 | &mut self, |
| 1903 | path: ProjectPath, | 1903 | path: ProjectPath, |
| 1904 | cx: &mut ViewContext<Self>, | 1904 | cx: &mut WindowContext, |
| 1905 | ) -> Task< | 1905 | ) -> Task< |
| 1906 | Result<( | 1906 | Result<( |
| 1907 | Option<ProjectEntryId>, | 1907 | Option<ProjectEntryId>, |
| @@ -1910,7 +1910,7 @@ impl Workspace { · 2 unmodified lines | |||
| 1910 | > { | 1910 | > { |
| 1911 | let project = self.project().clone(); | 1911 | let project = self.project().clone(); |
| 1912 | let project_item = project.update(cx, |project, cx| project.open_path(path, cx)); | 1912 | let project_item = project.update(cx, |project, cx| project.open_path(path, cx)); |
| 1913 | cx.spawn(|_, mut cx| async move { | 1913 | cx.spawn(|mut cx| async move { |
| 1914 | let (project_entry_id, project_item) = project_item.await?; | 1914 | let (project_entry_id, project_item) = project_item.await?; |
| 1915 | let build_item = cx.update(|cx| { | 1915 | let build_item = cx.update(|cx| { |
| 1916 | cx.default_global::<ProjectItemBuilders>() | 1916 | cx.default_global::<ProjectItemBuilders>() |
| @@ -1980,7 +1980,7 @@ impl Workspace { · 63 unmodified lines | |||
| 1980 | } | 1980 | } |
| 1981 | } | 1981 | } |
| 1982 | 1982 | ||
| 1983 | pub fn activate_item(&mut self, item: &dyn ItemHandle, cx: &mut ViewContext<Self>) -> bool { | 1983 | pub fn activate_item(&mut self, item: &dyn ItemHandle, cx: &mut WindowContext) -> bool { |
| 1984 | let result = self.panes.iter().find_map(|pane| { | 1984 | let result = self.panes.iter().find_map(|pane| { |
| 1985 | pane.read(cx) | 1985 | pane.read(cx) |
| 1986 | .index_for_item(item) | 1986 | .index_for_item(item) |
| @@ -2003,7 +2003,7 @@ impl Workspace { · 16 unmodified lines | |||
| 2003 | } | 2003 | } |
| 2004 | } | 2004 | } |
| 2005 | 2005 | ||
| 2006 | pub fn activate_next_pane(&mut self, cx: &mut ViewContext<Self>) { | 2006 | pub fn activate_next_pane(&mut self, cx: &mut WindowContext) { |
| 2007 | let panes = self.center.panes(); | 2007 | let panes = self.center.panes(); |
| 2008 | if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { | 2008 | if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { |
| 2009 | let next_ix = (ix + 1) % panes.len(); | 2009 | let next_ix = (ix + 1) % panes.len(); |
| @@ -2012,7 +2012,7 @@ impl Workspace { · 2 unmodified lines | |||
| 2012 | } | 2012 | } |
| 2013 | } | 2013 | } |
| 2014 | 2014 | ||
| 2015 | pub fn activate_previous_pane(&mut self, cx: &mut ViewContext<Self>) { | 2015 | pub fn activate_previous_pane(&mut self, cx: &mut WindowContext) { |
| 2016 | let panes = self.center.panes(); | 2016 | let panes = self.center.panes(); |
| 2017 | if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { | 2017 | if let Some(ix) = panes.iter().position(|pane| **pane == self.active_pane) { |
| 2018 | let prev_ix = cmp::min(ix.wrapping_sub(1), panes.len() - 1); | 2018 | let prev_ix = cmp::min(ix.wrapping_sub(1), panes.len() - 1); |
| @@ -2024,7 +2024,7 @@ impl Workspace { · 5 unmodified lines | |||
| 2024 | pub fn activate_pane_in_direction( | 2024 | pub fn activate_pane_in_direction( |
| 2025 | &mut self, | 2025 | &mut self, |
| 2026 | direction: SplitDirection, | 2026 | direction: SplitDirection, |
| 2027 | cx: &mut ViewContext<Self>, | 2027 | cx: &mut WindowContext, |
| 2028 | ) { | 2028 | ) { |
| 2029 | if let Some(pane) = self.find_pane_in_direction(direction, cx) { | 2029 | if let Some(pane) = self.find_pane_in_direction(direction, cx) { |
| 2030 | cx.focus_view(pane); | 2030 | cx.focus_view(pane); |
| @@ -2048,7 +2048,7 @@ impl Workspace { · 17 unmodified lines | |||
| 2048 | fn find_pane_in_direction( | 2048 | fn find_pane_in_direction( |
| 2049 | &mut self, | 2049 | &mut self, |
| 2050 | direction: SplitDirection, | 2050 | direction: SplitDirection, |
| 2051 | cx: &mut ViewContext<Self>, | 2051 | cx: &AppContext, |
| 2052 | ) -> Option<&View<Pane>> { | 2052 | ) -> Option<&View<Pane>> { |
| 2053 | let Some(bounding_box) = self.center.bounding_box_for_pane(&self.active_pane) else { | 2053 | let Some(bounding_box) = self.center.bounding_box_for_pane(&self.active_pane) else { |
| 2054 | return None; | 2054 | return None; |
| @@ -2483,14 +2483,14 @@ impl Workspace { · 428 unmodified lines | |||
| 2483 | .any(|state| state.leader_id == peer_id) | 2483 | .any(|state| state.leader_id == peer_id) |
| 2484 | } | 2484 | } |
| 2485 | 2485 | ||
| 2486 | fn active_item_path_changed(&mut self, cx: &mut ViewContext<Self>) { | 2486 | fn active_item_path_changed(&mut self, cx: &mut WindowContext) { |
| 2487 | let active_entry = self.active_project_path(cx); | 2487 | let active_entry = self.active_project_path(cx); |
| 2488 | self.project | 2488 | self.project |
| 2489 | .update(cx, |project, cx| project.set_active_path(active_entry, cx)); | 2489 | .update(cx, |project, cx| project.set_active_path(active_entry, cx)); |
| 2490 | self.update_window_title(cx); | 2490 | self.update_window_title(cx); |
| 2491 | } | 2491 | } |
| 2492 | 2492 | ||
| 2493 | fn update_window_title(&mut self, cx: &mut ViewContext<Self>) { | 2493 | fn update_window_title(&mut self, cx: &mut WindowContext) { |
| 2494 | let project = self.project().read(cx); | 2494 | let project = self.project().read(cx); |
| 2495 | let mut title = String::new(); | 2495 | let mut title = String::new(); |
| 2496 | 2496 | ||
| @@ -2534,7 +2534,7 @@ impl Workspace { · 37 unmodified lines | |||
| 2534 | cx.set_window_title(&title); | 2534 | cx.set_window_title(&title); |
| 2535 | } | 2535 | } |
| 2536 | 2536 | ||
| 2537 | fn update_window_edited(&mut self, cx: &mut ViewContext<Self>) { | 2537 | fn update_window_edited(&mut self, cx: &mut WindowContext) { |
| 2538 | let is_edited = !self.project.read(cx).is_disconnected() | 2538 | let is_edited = !self.project.read(cx).is_disconnected() |
| 2539 | && self | 2539 | && self |
| 2540 | .items(cx) | 2540 | .items(cx) |
| @@ -2759,7 +2759,7 @@ impl Workspace { · 218 unmodified lines | |||
| 2759 | Ok(()) | 2759 | Ok(()) |
| 2760 | } | 2760 | } |
| 2761 | 2761 | ||
| 2762 | fn update_active_view_for_followers(&mut self, cx: &mut ViewContext<Self>) { | 2762 | fn update_active_view_for_followers(&mut self, cx: &mut WindowContext) { |
| 2763 | let mut is_project_item = true; | 2763 | let mut is_project_item = true; |
| 2764 | let mut update = proto::UpdateActiveView::default(); | 2764 | let mut update = proto::UpdateActiveView::default(); |
| 2765 | 2765 | ||
| @@ -2876,7 +2876,7 @@ impl Workspace { · 110 unmodified lines | |||
| 2876 | &self, | 2876 | &self, |
| 2877 | peer_id: PeerId, | 2877 | peer_id: PeerId, |
| 2878 | pane: &View<Pane>, | 2878 | pane: &View<Pane>, |
| 2879 | cx: &mut ViewContext<Self>, | 2879 | cx: &mut WindowContext, |
| 2880 | ) -> Option<View<SharedScreen>> { | 2880 | ) -> Option<View<SharedScreen>> { |
| 2881 | let call = self.active_call()?; | 2881 | let call = self.active_call()?; |
| 2882 | let room = call.read(cx).room()?.read(cx); | 2882 | let room = call.read(cx).room()?.read(cx); |
| @@ -2993,7 +2993,7 @@ impl Workspace { · 110 unmodified lines | |||
| 2993 | })); | 2993 | })); |
| 2994 | } | 2994 | } |
| 2995 | 2995 | ||
| 2996 | fn serialize_workspace(&self, cx: &mut ViewContext<Self>) { | 2996 | fn serialize_workspace(&self, cx: &mut WindowContext) { |
| 2997 | fn serialize_pane_handle(pane_handle: &View<Pane>, cx: &WindowContext) -> SerializedPane { | 2997 | fn serialize_pane_handle(pane_handle: &View<Pane>, cx: &WindowContext) -> SerializedPane { |
| 2998 | let (items, active) = { | 2998 | let (items, active) = { |
| 2999 | let pane = pane_handle.read(cx); | 2999 | let pane = pane_handle.read(cx); |
| @@ -3039,10 +3039,7 @@ impl Workspace { · 39 unmodified lines | |||
| 3039 | } | 3039 | } |
| 3040 | } | 3040 | } |
| 3041 | 3041 | ||
| 3042 | fn build_serialized_docks( | 3042 | fn build_serialized_docks(this: &Workspace, cx: &mut WindowContext) -> DockStructure { |
| 3043 | this: &Workspace, | ||
| 3044 | cx: &mut ViewContext<Workspace>, | ||
| 3045 | ) -> DockStructure { | ||
| 3046 | let left_dock = this.left_dock.read(cx); | 3043 | let left_dock = this.left_dock.read(cx); |
| 3047 | let left_visible = left_dock.is_open(); | 3044 | let left_visible = left_dock.is_open(); |
| 3048 | let left_active_panel = left_dock | 3045 | let left_active_panel = left_dock |
| @@ -3109,7 +3106,7 @@ impl Workspace { · 60 unmodified lines | |||
| 3109 | docks, | 3106 | docks, |
| 3110 | }; | 3107 | }; |
| 3111 | 3108 | ||
| 3112 | cx.spawn(|_, _| persistence::DB.save_workspace(serialized_workspace)) | 3109 | cx.spawn(|_| persistence::DB.save_workspace(serialized_workspace)) |
| 3113 | .detach(); | 3110 | .detach(); |
| 3114 | } | 3111 | } |
| 3115 | } | 3112 | } |
| @@ -3350,14 +3347,11 @@ impl Workspace { · 234 unmodified lines | |||
| 3350 | self.modal_layer.read(cx).has_active_modal() | 3347 | self.modal_layer.read(cx).has_active_modal() |
| 3351 | } | 3348 | } |
| 3352 | 3349 | ||
| 3353 | pub fn active_modal<V: ManagedView + 'static>( | 3350 | pub fn active_modal<V: ManagedView + 'static>(&mut self, cx: &AppContext) -> Option<View<V>> { |
| 3354 | &mut self, | ||
| 3355 | cx: &ViewContext<Self>, | ||
| 3356 | ) -> Option<View<V>> { | ||
| 3357 | self.modal_layer.read(cx).active_modal() | 3351 | self.modal_layer.read(cx).active_modal() |
| 3358 | } | 3352 | } |
| 3359 | 3353 | ||
| 3360 | pub fn toggle_modal<V: ModalView, B>(&mut self, cx: &mut ViewContext<Self>, build: B) | 3354 | pub fn toggle_modal<V: ModalView, B>(&mut self, cx: &mut WindowContext, build: B) |
| 3361 | where | 3355 | where |
| 3362 | B: FnOnce(&mut ViewContext<V>) -> V, | 3356 | B: FnOnce(&mut ViewContext<V>) -> V, |
| 3363 | { | 3357 | { |