From a16144baf1f2836abc0cbc3f2d46aa7c8ddd9573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Fri, 1 Oct 2021 19:39:50 +0300 Subject: [PATCH] Disable crossterm raw mode Without this change, the output of panic messages by miette would ignore newlines and become unreadable. --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 5e9478b02..65abca3bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -265,6 +265,7 @@ name = "engine-q" version = "0.1.0" dependencies = [ "assert_cmd", + "crossterm", "miette", "nu-cli", "nu-command", diff --git a/Cargo.toml b/Cargo.toml index 5ab8b8831..826e3d542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ members = ["crates/nu-cli", "crates/nu-engine", "crates/nu-parser", "crates/nu-c [dependencies] reedline = { git = "https://github.com/jntrnr/reedline", branch = "main" } +crossterm = "0.21.*" nu-cli = { path="./crates/nu-cli" } nu-command = { path="./crates/nu-command" } nu-engine = { path="./crates/nu-engine" } diff --git a/src/main.rs b/src/main.rs index 577a9c721..c10bf2c80 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,11 @@ mod tests; fn main() -> Result<()> { 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();