From ada1da48ca512784902f4001def74c13bb8b29a3 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 25 Dec 2023 03:47:03 -0500 Subject: [PATCH 1/4] Remove already-implemented comment --- crates/zed2/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rs index 06eb432014..a248e4537b 100644 --- a/crates/zed2/src/main.rs +++ b/crates/zed2/src/main.rs @@ -209,7 +209,6 @@ fn main() { project_symbols::init(cx); project_panel::init(Assets, cx); channel::init(&client, user_store.clone(), cx); - // diagnostics::init(cx); search::init(cx); semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx); vim::init(cx); From 8f3ea6ccb3e498912b3d03395de5603c1b3f1ad0 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 25 Dec 2023 03:47:28 -0500 Subject: [PATCH 2/4] Remove silencing of warnings and fix warnings --- crates/zed2/src/main.rs | 5 +---- crates/zed2/src/open_listener.rs | 11 +++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rs index a248e4537b..f1fd168ffd 100644 --- a/crates/zed2/src/main.rs +++ b/crates/zed2/src/main.rs @@ -1,6 +1,3 @@ -#![allow(unused_variables, dead_code, unused_mut)] -// todo!() this is to make transition easier. - // Allow binary to be called Zed for a nice application menu when running executable directly #![allow(non_snake_case)] @@ -411,7 +408,7 @@ async fn installation_id() -> Result<(String, bool)> { Ok((installation_id, false)) } -async fn restore_or_create_workspace(app_state: &Arc, mut cx: AsyncAppContext) { +async fn restore_or_create_workspace(app_state: &Arc, cx: AsyncAppContext) { async_maybe!({ if let Some(location) = workspace::last_opened_workspace_paths().await { cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))? diff --git a/crates/zed2/src/open_listener.rs b/crates/zed2/src/open_listener.rs index b45254f717..6db020a785 100644 --- a/crates/zed2/src/open_listener.rs +++ b/crates/zed2/src/open_listener.rs @@ -251,12 +251,11 @@ pub async fn handle_cli_connection( let wait = async move { if paths.is_empty() { let (done_tx, done_rx) = oneshot::channel(); - let _subscription = - workspace.update(&mut cx, |workspace, cx| { - cx.on_release(move |_, _, _| { - let _ = done_tx.send(()); - }) - }); + let _subscription = workspace.update(&mut cx, |_, cx| { + cx.on_release(move |_, _, _| { + let _ = done_tx.send(()); + }) + }); let _ = done_rx.await; } else { let _ = futures::future::try_join_all(item_release_futures) From 12fe64b1774a7650440be1da3f3ceae96041f8f8 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 25 Dec 2023 07:02:19 -0500 Subject: [PATCH 3/4] Fix more warnings --- crates/zed2/src/main.rs | 91 +++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rs index f1fd168ffd..8ddce12f99 100644 --- a/crates/zed2/src/main.rs +++ b/crates/zed2/src/main.rs @@ -250,7 +250,7 @@ fn main() { cx: &mut AppContext, ) { let task = workspace::open_paths(&paths, &app_state, None, cx); - cx.spawn(|cx| async move { + cx.spawn(|_| async move { if let Some((_window, results)) = task.await.log_err() { for result in results { if let Some(Err(e)) = result { @@ -311,53 +311,48 @@ fn main() { } let app_state = app_state.clone(); - let closure_client = client.clone(); - cx.spawn(move |mut cx| { - let client = closure_client.clone(); - async move { - while let Some(request) = open_rx.next().await { - match request { - OpenRequest::Paths { paths } => { - cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx)) - .ok(); - } - OpenRequest::CliConnection { connection } => { - let app_state = app_state.clone(); - cx.spawn(move |cx| { - handle_cli_connection(connection, app_state.clone(), cx) - }) - .detach(); - } - OpenRequest::JoinChannel { channel_id } => { - let app_state = app_state.clone(); - cx.update(|mut cx| { - cx.spawn(|cx| async move { - cx.update(|cx| { - workspace::join_channel(channel_id, app_state, None, cx) - })? - .await?; - anyhow::Ok(()) - }) - .detach_and_log_err(&mut cx); - }) - .log_err(); - } - OpenRequest::OpenChannelNotes { channel_id } => { - let app_state = app_state.clone(); - let open_notes_task = cx.spawn(|mut cx| async move { - let workspace_window = - workspace::get_any_active_workspace(app_state, cx.clone()) - .await?; - let _ = workspace_window - .update(&mut cx, |_, cx| { - ChannelView::open(channel_id, cx.view().clone(), cx) - })? - .await?; + cx.spawn(move |cx| async move { + while let Some(request) = open_rx.next().await { + match request { + OpenRequest::Paths { paths } => { + cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx)) + .ok(); + } + OpenRequest::CliConnection { connection } => { + let app_state = app_state.clone(); + cx.spawn(move |cx| { + handle_cli_connection(connection, app_state.clone(), cx) + }) + .detach(); + } + OpenRequest::JoinChannel { channel_id } => { + let app_state = app_state.clone(); + cx.update(|mut cx| { + cx.spawn(|cx| async move { + cx.update(|cx| { + workspace::join_channel(channel_id, app_state, None, cx) + })? + .await?; anyhow::Ok(()) - }); - cx.update(|cx| open_notes_task.detach_and_log_err(cx)) - .log_err(); - } + }) + .detach_and_log_err(&mut cx); + }) + .log_err(); + } + OpenRequest::OpenChannelNotes { channel_id } => { + let app_state = app_state.clone(); + let open_notes_task = cx.spawn(|mut cx| async move { + let workspace_window = + workspace::get_any_active_workspace(app_state, cx.clone()).await?; + let _ = workspace_window + .update(&mut cx, |_, cx| { + ChannelView::open(channel_id, cx.view().clone(), cx) + })? + .await?; + anyhow::Ok(()) + }); + cx.update(|cx| open_notes_task.detach_and_log_err(cx)) + .log_err(); } } } @@ -773,7 +768,7 @@ async fn watch_languages(fs: Arc, languages: Arc) fn watch_file_types(fs: Arc, cx: &mut AppContext) { use std::time::Duration; - cx.spawn(|mut cx| async move { + cx.spawn(|cx| async move { let mut events = fs .watch( "assets/icons/file_icons/file_types.json".as_ref(), From ee57658abe86a55b2f267cb4c853a90d500bef17 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 25 Dec 2023 13:30:27 +0100 Subject: [PATCH 4/4] Fix up superfluous mod declaration --- crates/zed2/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/zed2/src/main.rs b/crates/zed2/src/main.rs index 8ddce12f99..2fbb9c101d 100644 --- a/crates/zed2/src/main.rs +++ b/crates/zed2/src/main.rs @@ -53,8 +53,6 @@ use zed2::{ OpenListener, OpenRequest, }; -mod open_listener; - fn main() { menu::init(); zed_actions::init();