WIP
This commit is contained in:
parent
337a79e35f
commit
1c1b53ecf6
5 changed files with 452 additions and 421 deletions
|
@ -12,7 +12,7 @@ use client2::UserStore;
|
|||
use db2::kvp::KEY_VALUE_STORE;
|
||||
use fs2::RealFs;
|
||||
use futures::{channel::mpsc, SinkExt, StreamExt};
|
||||
use gpui2::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
|
||||
use gpui2::{Action, App, AppContext, AsyncAppContext, Context, MainThread, SemanticVersion, Task};
|
||||
use isahc::{prelude::Configurable, Request};
|
||||
use language2::LanguageRegistry;
|
||||
use log::LevelFilter;
|
||||
|
@ -24,7 +24,7 @@ use settings2::{
|
|||
default_settings, handle_settings_file_changes, watch_config_file, Settings, SettingsStore,
|
||||
};
|
||||
use simplelog::ConfigBuilder;
|
||||
use smol::process::Command;
|
||||
use smol::{future::FutureExt, process::Command};
|
||||
use std::{
|
||||
env,
|
||||
ffi::OsStr,
|
||||
|
@ -40,6 +40,7 @@ use std::{
|
|||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
use util::{
|
||||
async_maybe,
|
||||
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
|
||||
http::{self, HttpClient},
|
||||
paths, ResultExt,
|
||||
|
@ -242,7 +243,7 @@ fn main() {
|
|||
// .detach_and_log_err(cx)
|
||||
}
|
||||
Ok(None) | Err(_) => cx
|
||||
.spawn({
|
||||
.spawn_on_main({
|
||||
let app_state = app_state.clone();
|
||||
|cx| async move { restore_or_create_workspace(&app_state, cx).await }
|
||||
})
|
||||
|
@ -313,21 +314,33 @@ async fn installation_id() -> Result<String> {
|
|||
}
|
||||
}
|
||||
|
||||
async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
|
||||
if let Some(location) = workspace2::last_opened_workspace_paths().await {
|
||||
cx.update(|cx| workspace2::open_paths(location.paths().as_ref(), app_state, None, cx))?
|
||||
.await
|
||||
.log_err();
|
||||
} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
|
||||
cx.update(|cx| show_welcome_experience(app_state, cx));
|
||||
} else {
|
||||
cx.update(|cx| {
|
||||
workspace2::open_new(app_state, cx, |workspace, cx| {
|
||||
Editor::new_file(workspace, &Default::default(), cx)
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
}
|
||||
async fn restore_or_create_workspace(
|
||||
app_state: &Arc<AppState>,
|
||||
mut cx: MainThread<AsyncAppContext>,
|
||||
) {
|
||||
async_maybe!({
|
||||
if let Some(location) = workspace2::last_opened_workspace_paths().await {
|
||||
cx.update(|cx| workspace2::open_paths(location.paths().as_ref(), app_state, None, cx))?
|
||||
.await
|
||||
.log_err();
|
||||
} else if matches!(KEY_VALUE_STORE.read_kvp("******* THIS IS A BAD KEY PLEASE UNCOMMENT BELOW TO FIX THIS VERY LONG LINE *******"), Ok(None)) {
|
||||
// todo!(welcome)
|
||||
//} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
|
||||
//todo!()
|
||||
// cx.update(|cx| show_welcome_experience(app_state, cx));
|
||||
} else {
|
||||
cx.update(|cx| {
|
||||
workspace2::open_new(app_state, cx, |workspace, cx| {
|
||||
// todo!(editor)
|
||||
// Editor::new_file(workspace, &Default::default(), cx)
|
||||
})
|
||||
.detach();
|
||||
})?;
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.await
|
||||
.log_err();
|
||||
}
|
||||
|
||||
fn init_paths() {
|
||||
|
|
|
@ -7,7 +7,7 @@ pub use assets::*;
|
|||
use collections::HashMap;
|
||||
use gpui2::{
|
||||
point, px, AppContext, AsyncAppContext, AsyncWindowContext, MainThread, Point, Task,
|
||||
TitlebarOptions, WeakView, WindowBounds, WindowKind, WindowOptions,
|
||||
TitlebarOptions, WeakView, WindowBounds, WindowHandle, WindowKind, WindowOptions,
|
||||
};
|
||||
pub use only_instance::*;
|
||||
pub use open_listener::*;
|
||||
|
@ -165,7 +165,7 @@ pub async fn handle_cli_connection(
|
|||
if paths.is_empty() {
|
||||
let (done_tx, done_rx) = oneshot::channel();
|
||||
let _subscription =
|
||||
cx.update_window_root(&workspace, move |_, cx| {
|
||||
workspace.update(&mut cx, move |_, cx| {
|
||||
cx.on_release(|_, _| {
|
||||
let _ = done_tx.send(());
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue