Skip to content

Commit

Permalink
keep shell working even after an error
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Sep 6, 2024
1 parent ea63e15 commit eb3d152
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/deno_task_shell/src/shell/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 3 additions & 1 deletion crates/shell/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ")
Expand Down

0 comments on commit eb3d152

Please sign in to comment.