From c23d8cdf5ba479036eb796999b58d27498d6692f Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Fri, 31 Jan 2025 20:50:41 +0000 Subject: [PATCH] When using "Jump" with more than two splits, expand the transaction If there are more than two splits it may not be obvious why a transaction has been selected in the basic register mode, so expand the transaction to show the split that's in this register and also to indicate which split was followed to reach this transaction. --- gnucash/gnome/gnc-plugin-page-register.cpp | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-register.cpp b/gnucash/gnome/gnc-plugin-page-register.cpp index 533260e97a..b5f5fcf494 100644 --- a/gnucash/gnome/gnc-plugin-page-register.cpp +++ b/gnucash/gnome/gnc-plugin-page-register.cpp @@ -4985,6 +4985,8 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, Account* account; Account* leader; Split* split; + Split* other_split; + gboolean multiple_splits; ENTER ("(action %p, page %p)", simple, page); @@ -5013,6 +5015,9 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, return; } + other_split = xaccSplitGetOtherSplit (split); + multiple_splits = other_split == NULL; + leader = gnc_ledger_display_leader (priv->ledger); if (account == leader) { @@ -5040,8 +5045,7 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, return; } - Split* other_split = xaccSplitGetOtherSplit (split); - if (other_split == NULL) + if (multiple_splits) { other_split = jump_multiple_splits (account, split); } @@ -5105,11 +5109,30 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page); gsr = gnc_plugin_page_register_get_gsr (new_page); + SplitRegister *new_page_reg = gnc_ledger_display_get_split_register (gsr->ledger); + gboolean jump_twice = FALSE; + + /* Selecting the split (instead of just the transaction to open the "other" + * account) requires jumping a second time after expanding the transaction, + * in the basic and auto ledger modes. + */ + if (new_page_reg->style != REG_STYLE_JOURNAL) + jump_twice = TRUE; + /* Test for visibility of split */ if (gnc_split_reg_clear_filter_for_split (gsr, split)) gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(new_page)); gnc_split_reg_jump_to_split (gsr, split); + + if (multiple_splits && jump_twice) + { + /* Expand the transaction for the basic and auto ledger to identify the + * split in this register, but only if there are more than two splits. + */ + gnc_split_register_expand_current_trans (new_page_reg, TRUE); + gnc_split_reg_jump_to_split (gsr, split); + } LEAVE (" "); }