From 7701c6b1d4a0f42043e562e0d5ed82c236f06958 Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Sun, 6 Mar 2022 17:22:18 +0000 Subject: [PATCH] added real index column to history (#4756) --- Cargo.lock | 2 +- crates/nu-command/src/core_commands/history.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d808ac133..c778d60ae1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3406,7 +3406,7 @@ dependencies = [ [[package]] name = "reedline" version = "0.2.0" -source = "git+https://github.com/nushell/reedline?branch=main#7c5f20d25248901872a91da6c235ae942e815b03" +source = "git+https://github.com/nushell/reedline?branch=main#0d6e26276abd8792ee631581a073126d0f845445" dependencies = [ "chrono", "crossterm", diff --git a/crates/nu-command/src/core_commands/history.rs b/crates/nu-command/src/core_commands/history.rs index db7c1d661a..e2ac8bff19 100644 --- a/crates/nu-command/src/core_commands/history.rs +++ b/crates/nu-command/src/core_commands/history.rs @@ -53,8 +53,19 @@ impl Command for History { if let Ok(contents) = contents { Ok(contents .lines() - .map(move |x| Value::String { - val: decode_newlines(x), + .enumerate() + .map(move |(index, command)| Value::Record { + cols: vec!["command".to_string(), "index".to_string()], + vals: vec![ + Value::String { + val: decode_newlines(command), + span: head, + }, + Value::Int { + val: index as i64, + span: head, + }, + ], span: head, }) .collect::>()