From 5c8b41dd5460a39f0b0461cb05be3662177c34ee Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 20 Apr 2023 08:33:45 -0700 Subject: [PATCH 1/4] Remove stable guard for copilot --- crates/copilot/src/copilot.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 1967c3cd14..09ee894340 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -35,15 +35,6 @@ actions!( ); pub fn init(http: Arc, node_runtime: Arc, cx: &mut AppContext) { - // Disable Copilot for stable releases. - if *cx.global::() == ReleaseChannel::Stable { - cx.update_global::(|filter, _cx| { - filter.filtered_namespaces.insert(COPILOT_NAMESPACE); - filter.filtered_namespaces.insert(COPILOT_AUTH_NAMESPACE); - }); - return; - } - let copilot = cx.add_model({ let node_runtime = node_runtime.clone(); move |cx| Copilot::start(http, node_runtime, cx) From f5bbb41cc2e1e36199a95ca8d51d580393bc4593 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 20 Apr 2023 08:34:50 -0700 Subject: [PATCH 2/4] Remove import --- crates/copilot/src/copilot.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 09ee894340..8229aaa36a 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -21,8 +21,7 @@ use std::{ sync::Arc, }; use util::{ - channel::ReleaseChannel, fs::remove_matching, github::latest_github_release, http::HttpClient, - paths, ResultExt, + fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt, }; const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth"; From ad8162fc9cf0109b2ebca8420ffc4201e606195d Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 20 Apr 2023 08:36:29 -0700 Subject: [PATCH 3/4] Make sign_in init conditional --- crates/copilot/src/sign_in.rs | 74 +++++++++++++++++------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/crates/copilot/src/sign_in.rs b/crates/copilot/src/sign_in.rs index dc09ddf3f2..3b949217bc 100644 --- a/crates/copilot/src/sign_in.rs +++ b/crates/copilot/src/sign_in.rs @@ -23,51 +23,51 @@ struct OpenGithub; const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot"; pub fn init(cx: &mut AppContext) { - let copilot = Copilot::global(cx).unwrap(); + if let Some(copilot) = Copilot::global(cx) { + let mut code_verification: Option> = None; + cx.observe(&copilot, move |copilot, cx| { + let status = copilot.read(cx).status(); - let mut code_verification: Option> = None; - cx.observe(&copilot, move |copilot, cx| { - let status = copilot.read(cx).status(); - - match &status { - crate::Status::SigningIn { prompt } => { - if let Some(code_verification_handle) = code_verification.as_mut() { - if cx.has_window(code_verification_handle.window_id()) { - code_verification_handle.update(cx, |code_verification_view, cx| { - code_verification_view.set_status(status, cx) - }); - cx.activate_window(code_verification_handle.window_id()); - } else { + match &status { + crate::Status::SigningIn { prompt } => { + if let Some(code_verification_handle) = code_verification.as_mut() { + if cx.has_window(code_verification_handle.window_id()) { + code_verification_handle.update(cx, |code_verification_view, cx| { + code_verification_view.set_status(status, cx) + }); + cx.activate_window(code_verification_handle.window_id()); + } else { + create_copilot_auth_window(cx, &status, &mut code_verification); + } + } else if let Some(_prompt) = prompt { create_copilot_auth_window(cx, &status, &mut code_verification); } - } else if let Some(_prompt) = prompt { - create_copilot_auth_window(cx, &status, &mut code_verification); } - } - Status::Authorized | Status::Unauthorized => { - if let Some(code_verification) = code_verification.as_ref() { - code_verification.update(cx, |code_verification, cx| { - code_verification.set_status(status, cx) - }); + Status::Authorized | Status::Unauthorized => { + if let Some(code_verification) = code_verification.as_ref() { + code_verification.update(cx, |code_verification, cx| { + code_verification.set_status(status, cx) + }); - cx.platform().activate(true); - cx.activate_window(code_verification.window_id()); + cx.platform().activate(true); + cx.activate_window(code_verification.window_id()); + } + } + _ => { + if let Some(code_verification) = code_verification.take() { + cx.remove_window(code_verification.window_id()); + } } } - _ => { - if let Some(code_verification) = code_verification.take() { - cx.remove_window(code_verification.window_id()); - } - } - } - }) - .detach(); + }) + .detach(); - cx.add_action( - |code_verification: &mut CopilotCodeVerification, _: &ClickedConnect, _| { - code_verification.connect_clicked = true; - }, - ); + cx.add_action( + |code_verification: &mut CopilotCodeVerification, _: &ClickedConnect, _| { + code_verification.connect_clicked = true; + }, + ); + } } fn create_copilot_auth_window( From c1daf0fc36f5b95d76e6bee4c7b499983fe6a1cd Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 20 Apr 2023 08:54:44 -0700 Subject: [PATCH 4/4] Fix format --- crates/editor/src/editor_tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index ce293ed064..646a8f33d6 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -4371,7 +4371,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext) cx.set_state( &[ "one ", // - "twoˇ", // + "twoˇ", // "three ", // "four", // ] @@ -4446,7 +4446,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext) &[ "one", // "", // - "twoˇ", // + "twoˇ", // "", // "three", // "four", // @@ -4461,7 +4461,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext) cx.assert_editor_state( &[ "one ", // - "twoˇ", // + "twoˇ", // "three ", // "four", // ]