WIP: Compiling, many warnings, haven't tested

Nathan Sobo created

Change summary

crates/gpui/src/app.rs                    |  1 
crates/gpui/src/app/window.rs             |  2 
crates/project_panel/src/project_panel.rs |  3 
crates/zed/src/zed.rs                     | 60 ++++++++++++------------
4 files changed, 34 insertions(+), 32 deletions(-)

Detailed changes

crates/gpui/src/app.rs 🔗

@@ -388,6 +388,7 @@ impl AsyncAppContext {
         self.update_window(window_id, |cx| cx.activate_window());
     }
 
+    // TODO: Can we eliminate this method and move it to WindowContext then call it with update_window?s
     pub fn prompt(
         &mut self,
         window_id: usize,

crates/gpui/src/app/window.rs 🔗

@@ -841,7 +841,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {
         self.window.platform_window.zoom();
     }
 
-    pub fn toggle_window_full_screen(&self) {
+    pub fn toggle_full_screen(&self) {
         self.window.platform_window.toggle_full_screen();
     }
 

crates/project_panel/src/project_panel.rs 🔗

@@ -1943,7 +1943,8 @@ mod tests {
         let mut result = Vec::new();
         let mut project_entries = HashSet::new();
         let mut has_editor = false;
-        cx.render(panel, |panel, cx| {
+
+        panel.update(cx, |panel, cx| {
             panel.for_each_visible_entry(range, cx, |project_entry, details, _| {
                 if details.is_editing {
                     assert!(!has_editor, "duplicate editor entry");

crates/zed/src/zed.rs 🔗

@@ -105,7 +105,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
                 .titlebar_item()
                 .and_then(|item| item.downcast::<CollabTitlebarItem>())
             {
-                cx.as_mut().defer(move |cx| {
+                cx.defer(move |_, cx| {
                     item.update(cx, |item, cx| {
                         item.toggle_contacts_popover(&Default::default(), cx);
                     });
@@ -380,17 +380,18 @@ fn restart(_: &Restart, cx: &mut gpui::AppContext) {
     let should_confirm = cx.global::<Settings>().confirm_quit;
     cx.spawn(|mut cx| async move {
         if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
-            let answer = cx
-                .prompt(
-                    workspace.window_id(),
-                    PromptLevel::Info,
-                    "Are you sure you want to restart?",
-                    &["Restart", "Cancel"],
-                )
-                .next()
-                .await;
-            if answer != Some(0) {
-                return Ok(());
+            let answer = cx.prompt(
+                workspace.window_id(),
+                PromptLevel::Info,
+                "Are you sure you want to restart?",
+                &["Restart", "Cancel"],
+            );
+
+            if let Some(mut answer) = answer {
+                let answer = answer.next().await;
+                if answer != Some(0) {
+                    return Ok(());
+                }
             }
         }
 
@@ -424,17 +425,18 @@ fn quit(_: &Quit, cx: &mut gpui::AppContext) {
     let should_confirm = cx.global::<Settings>().confirm_quit;
     cx.spawn(|mut cx| async move {
         if let (true, Some(workspace)) = (should_confirm, workspaces.first()) {
-            let answer = cx
-                .prompt(
-                    workspace.window_id(),
-                    PromptLevel::Info,
-                    "Are you sure you want to quit?",
-                    &["Quit", "Cancel"],
-                )
-                .next()
-                .await;
-            if answer != Some(0) {
-                return Ok(());
+            let answer = cx.prompt(
+                workspace.window_id(),
+                PromptLevel::Info,
+                "Are you sure you want to quit?",
+                &["Quit", "Cancel"],
+            );
+
+            if let Some(mut answer) = answer {
+                let answer = answer.next().await;
+                if answer != Some(0) {
+                    return Ok(());
+                }
             }
         }
 
@@ -712,7 +714,7 @@ mod tests {
             .await;
         assert_eq!(cx.window_ids().len(), 1);
         let workspace_1 = cx
-            .root_view(cx.window_ids()[0])
+            .read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
             .unwrap()
             .downcast::<Workspace>()
             .unwrap();
@@ -746,9 +748,8 @@ mod tests {
         .await;
         assert_eq!(cx.window_ids().len(), 2);
         let workspace_1 = cx
-            .root_view(window_id)
+            .read_window(window_id, |cx| cx.root_view().clone())
             .unwrap()
-            .clone()
             .downcast::<Workspace>()
             .unwrap();
         workspace_1.read_with(cx, |workspace, cx| {
@@ -779,9 +780,8 @@ mod tests {
 
         // When opening the workspace, the window is not in a edited state.
         let workspace = cx
-            .root_view(cx.window_ids()[0])
+            .read_window(cx.window_ids()[0], |cx| cx.root_view().clone())
             .unwrap()
-            .clone()
             .downcast::<Workspace>()
             .unwrap();
         let editor = workspace.read_with(cx, |workspace, cx| {
@@ -851,11 +851,11 @@ mod tests {
 
         let window_id = *cx.window_ids().first().unwrap();
         let workspace = cx
-            .root_view(window_id)
+            .read_window(window_id, |cx| cx.root_view().clone())
             .unwrap()
-            .clone()
             .downcast::<Workspace>()
             .unwrap();
+
         let editor = workspace.update(cx, |workspace, cx| {
             workspace
                 .active_item(cx)