From eb3d152f8d5da840a170ea4592880b039d5b9e0c Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Fri, 6 Sep 2024 06:09:56 -0400 Subject: [PATCH] keep shell working even after an error --- crates/deno_task_shell/src/shell/types.rs | 4 ++++ crates/shell/src/main.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/deno_task_shell/src/shell/types.rs b/crates/deno_task_shell/src/shell/types.rs index f78ba66..a66e442 100644 --- a/crates/deno_task_shell/src/shell/types.rs +++ b/crates/deno_task_shell/src/shell/types.rs @@ -159,6 +159,10 @@ impl ShellState { state.token = self.token.child_token(); state } + + pub fn reset_cancellation_token(&mut self) { + self.token = CancellationToken::default(); + } } #[derive(Debug, PartialEq, Eq)] diff --git a/crates/shell/src/main.rs b/crates/shell/src/main.rs index fda7872..7fc794f 100644 --- a/crates/shell/src/main.rs +++ b/crates/shell/src/main.rs @@ -66,6 +66,9 @@ async fn interactive() -> anyhow::Result<()> { let mut prev_exit_code = 0; loop { + // Reset cancellation flag + state.reset_cancellation_token(); + // Display the prompt and read a line let readline = if prev_exit_code == 0 { let cwd = state.cwd().to_string_lossy().to_string(); @@ -77,7 +80,6 @@ async fn interactive() -> anyhow::Result<()> { .strip_prefix(home_str) .map(|stripped| format!("~{}$ ", stripped.replace('\\', "/"))) .unwrap_or_else(|| format!("{}$ ", cwd)); - rl.readline(&prompt) } else { rl.readline("xxx ")