texthistory: add barriers after final grouping
We don't want to allow new items to be grouped into a previous action group after the end_user_action() is called. This ensures that we add a barrier action in those conditions.
Fixes #4276 (closed)
This also improves undo grouping when overwriting a selection.