Allow forcing an undo group to be closed

This commit is contained in:
Allan Odgaard
2014-09-02 18:53:26 +02:00
parent 4d6a8174f0
commit e91bf08e69
2 changed files with 4 additions and 3 deletions

View File

@@ -25,12 +25,13 @@ namespace ng
}
}
void undo_manager_t::end_undo_group (ranges_t const& ranges)
void undo_manager_t::end_undo_group (ranges_t const& ranges, bool force)
{
if(--_nesting_count == 0 && _changes)
if((--_nesting_count == 0 || force) && _changes)
{
_records[_index-1].post_selection = ranges;
_records[_index-1].post_revision = _buffer.bump_revision();
_changes = 0;
}
}

View File

@@ -15,7 +15,7 @@ namespace ng
bool can_redo () const;
void begin_undo_group (ranges_t const& ranges);
void end_undo_group (ranges_t const& ranges);
void end_undo_group (ranges_t const& ranges, bool force = false);
ranges_t undo ();
ranges_t redo ();