wip
This commit is contained in:
parent
98ed13c5ed
commit
e1133d94fe
|
@ -25,8 +25,8 @@ use nu_cmd_base::util::get_init_cwd;
|
||||||
use nu_lsp::LanguageServer;
|
use nu_lsp::LanguageServer;
|
||||||
use nu_path::canonicalize_with;
|
use nu_path::canonicalize_with;
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::{ctrlc, EngineState},
|
engine::EngineState, report_error_new, ByteStream, PipelineData, ShellError, Span, Spanned,
|
||||||
report_error_new, ByteStream, PipelineData, ShellError, Span, Spanned, Value,
|
Value,
|
||||||
};
|
};
|
||||||
use nu_std::load_standard_library;
|
use nu_std::load_standard_library;
|
||||||
use nu_utils::perf;
|
use nu_utils::perf;
|
||||||
|
@ -70,9 +70,8 @@ fn main() -> Result<()> {
|
||||||
report_error_new(&engine_state, &err);
|
report_error_new(&engine_state, &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ctrlc_handlers = ctrlc::Handlers::new();
|
|
||||||
// TODO: make this conditional in the future
|
// TODO: make this conditional in the future
|
||||||
ctrlc_protection(&mut engine_state, &ctrlc_handlers);
|
ctrlc_protection(&mut engine_state);
|
||||||
|
|
||||||
// Begin: Default NU_LIB_DIRS, NU_PLUGIN_DIRS
|
// Begin: Default NU_LIB_DIRS, NU_PLUGIN_DIRS
|
||||||
// Set default NU_LIB_DIRS and NU_PLUGIN_DIRS here before the env.nu is processed. If
|
// Set default NU_LIB_DIRS and NU_PLUGIN_DIRS here before the env.nu is processed. If
|
||||||
|
|
|
@ -2,18 +2,21 @@ use nu_protocol::{
|
||||||
engine::{ctrlc::Handlers, EngineState},
|
engine::{ctrlc::Handlers, EngineState},
|
||||||
Signals,
|
Signals,
|
||||||
};
|
};
|
||||||
use std::sync::{atomic::AtomicBool, Arc};
|
use std::sync::{
|
||||||
|
atomic::{AtomicBool, Ordering},
|
||||||
|
Arc,
|
||||||
|
};
|
||||||
|
|
||||||
pub(crate) fn ctrlc_protection(engine_state: &mut EngineState, ctrlc_handlers: &Handlers) {
|
pub(crate) fn ctrlc_protection(engine_state: &mut EngineState) {
|
||||||
let interrupt = Arc::new(AtomicBool::new(false));
|
let interrupt = Arc::new(AtomicBool::new(false));
|
||||||
engine_state.set_signals(Signals::new(interrupt.clone()));
|
engine_state.set_signals(Signals::new(interrupt.clone()));
|
||||||
{
|
|
||||||
let ctrlc_handlers = ctrlc_handlers.clone();
|
|
||||||
ctrlc::set_handler(move || {
|
|
||||||
ctrlc_handlers.run();
|
|
||||||
})
|
|
||||||
.expect("Error setting Ctrl-C handler");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let ctrlc_handlers = Handlers::new();
|
||||||
engine_state.ctrlc_handlers = Some(ctrlc_handlers.clone());
|
engine_state.ctrlc_handlers = Some(ctrlc_handlers.clone());
|
||||||
|
|
||||||
|
ctrlc::set_handler(move || {
|
||||||
|
interrupt.store(true, Ordering::Relaxed);
|
||||||
|
ctrlc_handlers.run();
|
||||||
|
})
|
||||||
|
.expect("Error setting Ctrl-C handler");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user