Do not hold any tasks by default and no other terminals (#16847)

This commit is contained in:
Kirill Bulatov 2024-08-27 01:48:34 +03:00 committed by GitHub
parent 29745ae229
commit f64f85eb1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 89 deletions

View File

@ -345,10 +345,6 @@ impl TerminalBuilder {
alacritty_terminal::tty::Options { alacritty_terminal::tty::Options {
shell: alac_shell, shell: alac_shell,
working_directory: working_directory.clone(), 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, hold: false,
env: env.into_iter().collect(), env: env.into_iter().collect(),
} }

View File

@ -1014,9 +1014,8 @@ fn open_settings_file(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use anyhow::anyhow;
use assets::Assets; use assets::Assets;
use collections::{HashMap, HashSet}; use collections::HashSet;
use editor::{display_map::DisplayRow, scroll::Autoscroll, DisplayPoint, Editor}; use editor::{display_map::DisplayRow, scroll::Autoscroll, DisplayPoint, Editor};
use gpui::{ use gpui::{
actions, Action, AnyWindowHandle, AppContext, AssetSource, BorrowAppContext, Entity, actions, Action, AnyWindowHandle, AppContext, AssetSource, BorrowAppContext, Entity,
@ -1030,7 +1029,6 @@ mod tests {
path::{Path, PathBuf}, path::{Path, PathBuf},
time::Duration, time::Duration,
}; };
use task::{HideStrategy, RevealStrategy, Shell, SpawnInTerminal};
use theme::{ThemeRegistry, ThemeSettings}; use theme::{ThemeRegistry, ThemeSettings};
use workspace::{ use workspace::{
item::{Item, ItemHandle}, item::{Item, ItemHandle},
@ -3356,88 +3354,6 @@ mod tests {
cx.run_until_parked(); 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<AppState> { pub(crate) fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {
init_test_with_state(cx, cx.update(|cx| AppState::test(cx))) init_test_with_state(cx, cx.update(|cx| AppState::test(cx)))
} }