From 3278d290be10ffcd636a4ee07fb6839971ac86f9 Mon Sep 17 00:00:00 2001 From: unrelentingtech Date: Mon, 5 Sep 2022 14:31:26 +0300 Subject: [PATCH] Avoid update_last_command_context "No command run" error (#6483) * Avoid update_last_command_context "No command run" error When using `executehostcommand` bindings without having run actual user input commands yet, update_last_command_context is guaranteed to fail. A function has been added to reedline that allows checking for this case. * Update to most recent reedline Includes bugfixes around the (SQlite) history Co-authored-by: sholderbach --- Cargo.lock | 3 +-- Cargo.toml | 3 +++ crates/nu-cli/src/repl.rs | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 962f01b7ed..44ca715769 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4078,8 +4078,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d84e8704e9eb141e73ac426c72af95eb195d4c3221a11ea92d5709f4a025adb5" +source = "git+https://github.com/nushell/reedline?branch=main#fe889ae5c4b4fa7492cf6f138ccd4274b0f682cf" dependencies = [ "chrono", "crossterm 0.24.0", diff --git a/Cargo.toml b/Cargo.toml index f0dc7df139..35a65e7022 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,3 +121,6 @@ debug = false [[bin]] name = "nu" path = "src/main.rs" + +[patch.crates-io] +reedline = { git = "https://github.com/nushell/reedline", branch = "main" } diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index de245e0406..c1168ce9d5 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -324,7 +324,8 @@ pub fn evaluate_repl( Ok(Signal::Success(s)) => { let history_supports_meta = matches!(config.history_file_format, HistoryFileFormat::Sqlite); - if history_supports_meta && !s.is_empty() { + if history_supports_meta && !s.is_empty() && line_editor.has_last_command_context() + { line_editor .update_last_command_context(&|mut c| { c.start_timestamp = Some(chrono::Utc::now()); @@ -445,7 +446,8 @@ pub fn evaluate_repl( }, ); - if history_supports_meta && !s.is_empty() { + if history_supports_meta && !s.is_empty() && line_editor.has_last_command_context() + { line_editor .update_last_command_context(&|mut c| { c.duration = Some(cmd_duration);