From 92bc66580245e53eab25910796d0c9a79dedf840 Mon Sep 17 00:00:00 2001 From: Michael Cuffaro Date: Sun, 13 Oct 2024 09:05:56 -0400 Subject: [PATCH] include redo stack in history --- src/main.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index e4e4729..dc77de8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -777,28 +777,25 @@ async fn main() -> Result<()> { } Commands::History {} => { let valve = build_valve(&cli.source, &cli.database).expect(BUILD_ERROR); - let redo_history = get_db_records_to_redo(&valve.pool, 1).await?; + let mut redo_history = valve.get_changes_to_redo(0).await?; let next_redo = match redo_history.len() { 0 => 0, - 1 => { - let history_id = redo_history[0] - .try_get::("history_id") - .expect("No 'history_id' in row"); - history_id as u16 - } - _ => panic!("Too many redos"), - }; - if next_redo != 0 { - let last_undo = convert_undo_or_redo_record_to_change(&redo_history[0])?; - println!("▲ {} {}", last_undo.history_id, last_undo.message); + _ => redo_history[0].history_id, }; + redo_history.reverse(); + for redo in &redo_history { + if redo.history_id == next_redo { + println!("▲ {} {}", redo.history_id, redo.message); + } else { + println!(" {} {}", redo.history_id, redo.message); + } + } let undo_history = valve.get_changes_to_undo(0).await?; let next_undo = match undo_history.len() { 0 => 0, _ => undo_history[0].history_id, }; - for undo in &undo_history { if undo.history_id == next_undo { let line = format!("▼ {} {}", undo.history_id, undo.message);