Disable crossterm raw mode

Without this change, the output of panic messages by miette would ignore
newlines and become unreadable.
This commit is contained in:
Jakub Žádník 2021-10-01 19:39:50 +03:00
parent 5a5205d5d9
commit a16144baf1
3 changed files with 7 additions and 0 deletions

1
Cargo.lock generated
View File

@ -265,6 +265,7 @@ name = "engine-q"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"assert_cmd", "assert_cmd",
"crossterm",
"miette", "miette",
"nu-cli", "nu-cli",
"nu-command", "nu-command",

View File

@ -10,6 +10,7 @@ members = ["crates/nu-cli", "crates/nu-engine", "crates/nu-parser", "crates/nu-c
[dependencies] [dependencies]
reedline = { git = "https://github.com/jntrnr/reedline", branch = "main" } reedline = { git = "https://github.com/jntrnr/reedline", branch = "main" }
crossterm = "0.21.*"
nu-cli = { path="./crates/nu-cli" } nu-cli = { path="./crates/nu-cli" }
nu-command = { path="./crates/nu-command" } nu-command = { path="./crates/nu-command" }
nu-engine = { path="./crates/nu-engine" } nu-engine = { path="./crates/nu-engine" }

View File

@ -17,6 +17,11 @@ mod tests;
fn main() -> Result<()> { fn main() -> Result<()> {
miette::set_panic_hook(); miette::set_panic_hook();
let miette_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |x| {
crossterm::terminal::disable_raw_mode().unwrap();
miette_hook(x);
}));
let engine_state = create_default_context(); let engine_state = create_default_context();