Implement activity indicator in zed2

This commit is contained in:
Max Brunsfeld 2023-11-29 17:18:21 -08:00
parent c95a7c7387
commit e49325080c
10 changed files with 436 additions and 61 deletions

View file

@ -4481,50 +4481,54 @@ pub fn create_and_open_local_file(
// })
// }
// pub fn restart(_: &Restart, cx: &mut AppContext) {
// let should_confirm = settings::get::<WorkspaceSettings>(cx).confirm_quit;
// cx.spawn(|mut cx| async move {
// let mut workspace_windows = cx
// .windows()
// .into_iter()
// .filter_map(|window| window.downcast::<Workspace>())
// .collect::<Vec<_>>();
pub fn restart(_: &Restart, cx: &mut AppContext) {
let should_confirm = WorkspaceSettings::get_global(cx).confirm_quit;
let mut workspace_windows = cx
.windows()
.into_iter()
.filter_map(|window| window.downcast::<Workspace>())
.collect::<Vec<_>>();
// // If multiple windows have unsaved changes, and need a save prompt,
// // prompt in the active window before switching to a different window.
// workspace_windows.sort_by_key(|window| window.is_active(&cx) == Some(false));
// If multiple windows have unsaved changes, and need a save prompt,
// prompt in the active window before switching to a different window.
workspace_windows.sort_by_key(|window| window.is_active(&cx) == Some(false));
// if let (true, Some(window)) = (should_confirm, workspace_windows.first()) {
// let answer = window.prompt(
// PromptLevel::Info,
// "Are you sure you want to restart?",
// &["Restart", "Cancel"],
// &mut cx,
// );
let mut prompt = None;
if let (true, Some(window)) = (should_confirm, workspace_windows.first()) {
prompt = window
.update(cx, |_, cx| {
cx.prompt(
PromptLevel::Info,
"Are you sure you want to restart?",
&["Restart", "Cancel"],
)
})
.ok();
}
// if let Some(mut answer) = answer {
// let answer = answer.next().await;
// if answer != Some(0) {
// return Ok(());
// }
// }
// }
cx.spawn(|mut cx| async move {
if let Some(mut prompt) = prompt {
let answer = prompt.await?;
if answer != 0 {
return Ok(());
}
}
// // If the user cancels any save prompt, then keep the app open.
// for window in workspace_windows {
// if let Some(should_close) = window.update_root(&mut cx, |workspace, cx| {
// workspace.prepare_to_close(true, cx)
// }) {
// if !should_close.await? {
// return Ok(());
// }
// }
// }
// cx.platform().restart();
// anyhow::Ok(())
// })
// .detach_and_log_err(cx);
// }
// If the user cancels any save prompt, then keep the app open.
for window in workspace_windows {
if let Ok(should_close) = window.update(&mut cx, |workspace, cx| {
workspace.prepare_to_close(true, cx)
}) {
if !should_close.await? {
return Ok(());
}
}
}
cx.update(|cx| cx.restart())
})
.detach_and_log_err(cx);
}
fn parse_pixel_position_env_var(value: &str) -> Option<Point<GlobalPixels>> {
let mut parts = value.split(',');