mirror of
https://github.com/nushell/nushell.git
synced 2025-01-11 08:48:23 +01:00
Fix while ctrlc behavior (#7195)
Currently while didn't respect ctrl-c, and thus non-terminating loops couldn't be interrupted. This patch fixes this.
This commit is contained in:
parent
eb875ea949
commit
c9f9078726
@ -1,3 +1,5 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use nu_engine::{eval_block, eval_expression, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Block, Command, EngineState, Stack};
|
||||
@ -46,6 +48,12 @@ impl Command for While {
|
||||
let block: Block = call.req(engine_state, stack, 1)?;
|
||||
|
||||
loop {
|
||||
if let Some(ctrlc) = &engine_state.ctrlc {
|
||||
if ctrlc.load(Ordering::SeqCst) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let result = eval_expression(engine_state, stack, cond)?;
|
||||
match &result {
|
||||
Value::Bool { val, .. } => {
|
||||
|
Loading…
Reference in New Issue
Block a user