Fetch last workspace explicitly when starting Zed
co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
db3119b553
commit
5a29a74956
5 changed files with 53 additions and 35 deletions
|
@ -169,7 +169,7 @@ fn main() {
|
|||
cx.platform().activate(true);
|
||||
let paths = collect_path_args();
|
||||
if paths.is_empty() {
|
||||
cx.dispatch_global_action(NewFile);
|
||||
restore_or_create_workspace(cx);
|
||||
} else {
|
||||
cx.dispatch_global_action(OpenPaths { paths });
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ fn main() {
|
|||
cx.spawn(|cx| handle_cli_connection(connection, app_state.clone(), cx))
|
||||
.detach();
|
||||
} else {
|
||||
cx.dispatch_global_action(NewFile);
|
||||
restore_or_create_workspace(cx);
|
||||
}
|
||||
cx.spawn(|cx| async move {
|
||||
while let Some(connection) = cli_connections_rx.next().await {
|
||||
|
@ -202,6 +202,16 @@ fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
fn restore_or_create_workspace(cx: &mut gpui::MutableAppContext) {
|
||||
if let Some(location) = workspace::last_opened_workspace_paths() {
|
||||
cx.dispatch_global_action(OpenPaths {
|
||||
paths: location.paths().as_ref().clone(),
|
||||
})
|
||||
} else {
|
||||
cx.dispatch_global_action(NewFile);
|
||||
}
|
||||
}
|
||||
|
||||
fn init_paths() {
|
||||
std::fs::create_dir_all(&*util::paths::CONFIG_DIR).expect("could not create config path");
|
||||
std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue