diff --git a/gnucash/register/ledger-core/split-register-load.c b/gnucash/register/ledger-core/split-register-load.c index d6963ed316f..db4fe3d947c 100644 --- a/gnucash/register/ledger-core/split-register-load.c +++ b/gnucash/register/ledger-core/split-register-load.c @@ -387,6 +387,17 @@ add_completions_from_pre_filter_slist (TableLayout* layout, GList *pre_filter_sl } } +static Split * +get_default_anchor_split (Transaction* pending_trans, Transaction* blank_trans, + Split* pending_anchor_split, Split* blank_split) +{ + // check if possible transaction paste to blank trans + if ((pending_trans == blank_trans) && pending_anchor_split) + return pending_anchor_split; + else + return blank_split; +} + void gnc_split_register_load (SplitRegister* reg, GList* slist, GList* pre_filter_slist, Account* default_account) @@ -406,6 +417,7 @@ gnc_split_register_load (SplitRegister* reg, GList* slist, Split* blank_split; Split* find_split; Split* split; + Split* pending_anchor_split = NULL; Table* table; GList* node; gnc_commodity *account_comm = NULL; @@ -595,9 +607,13 @@ gnc_split_register_load (SplitRegister* reg, GList* slist, { Split* pending_split = (Split*)node->data; if (!xaccTransStillHasSplit (pending_trans, pending_split)) continue; + if (g_list_find (slist, pending_split) != NULL) + { + pending_anchor_split = pending_split; continue; - + } + if (g_list_find_custom (slist, pending_trans, _find_split_with_parent_txn) != NULL) continue; @@ -635,8 +651,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist, // used in the setting the rows insensitive table->model->blank_trans_row = vcell_loc.virt_row; - gnc_split_register_add_transaction (reg, - blank_trans, blank_split, + // check if possible transaction paste to blank trans + Split* default_split = get_default_anchor_split (pending_trans, blank_trans, + pending_anchor_split, blank_split); + + gnc_split_register_add_transaction (reg, blank_trans, default_split, lead_cursor, split_cursor, multi_line, start_primary_color, info->blank_split_edited, @@ -759,8 +778,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist, // used in the setting the rows insensitive table->model->blank_trans_row = vcell_loc.virt_row; - gnc_split_register_add_transaction (reg, - blank_trans, blank_split, + // check if possible transaction paste to blank trans + Split* default_split = get_default_anchor_split (pending_trans, blank_trans, + pending_anchor_split, blank_split); + + gnc_split_register_add_transaction (reg, blank_trans, default_split, lead_cursor, split_cursor, multi_line, start_primary_color, info->blank_split_edited, @@ -855,7 +877,11 @@ gnc_split_register_load (SplitRegister* reg, GList* slist, // used in the setting the rows insensitive table->model->blank_trans_row = vcell_loc.virt_row; - gnc_split_register_add_transaction (reg, blank_trans, blank_split, + // check if possible transaction paste to blank trans + Split* default_split = get_default_anchor_split (pending_trans, blank_trans, + pending_anchor_split, blank_split); + + gnc_split_register_add_transaction (reg, blank_trans, default_split, lead_cursor, split_cursor, multi_line, start_primary_color, info->blank_split_edited,