From f64f85eb1e80d1027a978b749e0d04c00131aa17 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 27 Aug 2024 01:48:34 +0300 Subject: [PATCH] Do not hold any tasks by default and no other terminals (#16847) --- crates/terminal/src/terminal.rs | 4 -- crates/zed/src/zed.rs | 86 +-------------------------------- 2 files changed, 1 insertion(+), 89 deletions(-) diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index de83d54d91..7ef481d79c 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -345,10 +345,6 @@ impl TerminalBuilder { alacritty_terminal::tty::Options { shell: alac_shell, working_directory: working_directory.clone(), - #[cfg(target_os = "linux")] - hold: !matches!(shell.clone(), Shell::System), - // with hold: true, macOS gets tasks stuck on ctrl-c interrupts periodically - #[cfg(not(target_os = "linux"))] hold: false, env: env.into_iter().collect(), } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 4a1af6b7fa..300510c8be 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1014,9 +1014,8 @@ fn open_settings_file( #[cfg(test)] mod tests { use super::*; - use anyhow::anyhow; use assets::Assets; - use collections::{HashMap, HashSet}; + use collections::HashSet; use editor::{display_map::DisplayRow, scroll::Autoscroll, DisplayPoint, Editor}; use gpui::{ actions, Action, AnyWindowHandle, AppContext, AssetSource, BorrowAppContext, Entity, @@ -1030,7 +1029,6 @@ mod tests { path::{Path, PathBuf}, time::Duration, }; - use task::{HideStrategy, RevealStrategy, Shell, SpawnInTerminal}; use theme::{ThemeRegistry, ThemeSettings}; use workspace::{ item::{Item, ItemHandle}, @@ -3356,88 +3354,6 @@ mod tests { cx.run_until_parked(); } - #[gpui::test] - async fn test_spawn_terminal_task_real_fs(cx: &mut TestAppContext) { - let mut app_state = cx.update(|cx| AppState::test(cx)); - let state = Arc::get_mut(&mut app_state).unwrap(); - state.fs = Arc::new(fs::RealFs::default()); - let app_state = init_test_with_state(cx, app_state); - - cx.executor().allow_parking(); - let project_root = util::test::temp_tree(json!({ - "sample.txt": "" - })); - - let spawn_in_terminal = SpawnInTerminal { - command: "echo SAMPLE-OUTPUT".to_string(), - cwd: None, - env: HashMap::default(), - id: task::TaskId(String::from("sample-id")), - full_label: String::from("sample-full_label"), - label: String::from("sample-label"), - args: vec![], - command_label: String::from("sample-command_label"), - use_new_terminal: false, - allow_concurrent_runs: false, - reveal: RevealStrategy::Always, - hide: HideStrategy::Never, - shell: Shell::System, - }; - let project = Project::test(app_state.fs.clone(), [project_root.path()], cx).await; - let window = cx.add_window(|cx| Workspace::test_new(project, cx)); - cx.run_until_parked(); - cx.update(|cx| { - window - .update(cx, |_workspace, cx| { - cx.emit(workspace::Event::SpawnTask(Box::new(spawn_in_terminal))); - }) - .unwrap(); - }); - cx.run_until_parked(); - - run_until(|| { - cx.update(|cx| { - window - .read_with(cx, |workspace, cx| { - let terminal = workspace - .project() - .read(cx) - .local_terminal_handles() - .first() - .unwrap() - .upgrade() - .unwrap() - .read(cx); - terminal - .last_n_non_empty_lines(99) - .join("") - .contains("SAMPLE-OUTPUT") - }) - .unwrap() - }) - }) - .await; - } - - async fn run_until(predicate: impl Fn() -> bool) { - let timer = async { smol::Timer::after(std::time::Duration::from_secs(3)).await }; - - use futures::FutureExt as _; - use smol::future::FutureExt as _; - - async { - loop { - if predicate() { - return Ok(()); - } - smol::Timer::after(std::time::Duration::from_millis(10)).await; - } - } - .race(timer.map(|_| Err(anyhow!("condition timed out")))) - .await - .unwrap(); - } - pub(crate) fn init_test(cx: &mut TestAppContext) -> Arc { init_test_with_state(cx, cx.update(|cx| AppState::test(cx))) }