From 3a0473b5b4d45b2fa24284e7a0c8616855136cab Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 28 Oct 2022 22:45:13 -1000 Subject: [PATCH] fix: ui: fix regenerateScreens, it was not updating the journal And add to test suite. Fixes unreleased code. --- hledger-ui/Hledger/UI/UIState.hs | 9 +++++---- hledger-ui/test/uitest.org | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hledger-ui/Hledger/UI/UIState.hs b/hledger-ui/Hledger/UI/UIState.hs index 847be7f5c..5ddc8e94a 100644 --- a/hledger-ui/Hledger/UI/UIState.hs +++ b/hledger-ui/Hledger/UI/UIState.hs @@ -347,10 +347,11 @@ resetScreens d ui@UIState{astartupopts=origopts, ajournal=j, aScreen=s,aPrevScre where topscreen' = screenUpdate origopts d j $ lastDef s ss --- | Regenerate the content of the current and all parent screens --- from a new journal and reporting date (and current options), --- while preserving the screen navigation history. +-- | Given a new journal and reporting date, save the new journal in the ui state, +-- then regenerate the content of all screens in the stack +-- (using the ui state's current options), preserving the screen navigation history. +-- Note, does not save the reporting date. regenerateScreens :: Journal -> Day -> UIState -> UIState regenerateScreens j d ui@UIState{aopts=opts, aScreen=s,aPrevScreens=ss} = - ui{aScreen=screenUpdate opts d j s, aPrevScreens=map (screenUpdate opts d j) ss} + ui{ajournal=j, aScreen=screenUpdate opts d j s, aPrevScreens=map (screenUpdate opts d j) ss} diff --git a/hledger-ui/test/uitest.org b/hledger-ui/test/uitest.org index 06b033005..2ca7b7405 100644 --- a/hledger-ui/test/uitest.org +++ b/hledger-ui/test/uitest.org @@ -213,3 +213,11 @@ which has nice screenshots, but might be less up to date. ──────────────────────────── a:aa transactions (2/2) ─────────────────────────── 2021-01-02 a:aa 10 10 2021-01-03 a:aa:aaa 100 110 # <- selected + +** hledger-ui -f sample.journal saving, edit and change the "save" txn description and amount to "NEW" and $22, g # current screen shows new data after reload +───────────── sample.journal account balances matching saving (1/1) ──────────── + assets:bank:saving $22 + +** RIGHT # newly created screens show new data after reload +───────────── assets:bank:saving transactions matching saving (1/1) ──────────── + 2008-06-02 NEW as:ba:saving $22 $22