mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +00:00
LibGUI: Support merging of adjacent commands on the UndoStack
When pushing a new command on an undo stack, we will now attempt to merge it into the stack's current command. Merging is implemented by overriding the "merge_with(Command const&)" virtual on GUI::Command. :^)
This commit is contained in:
@@ -77,6 +77,12 @@ void UndoStack::push(NonnullOwnPtr<Command>&& command)
|
||||
finalize_current_combo();
|
||||
}
|
||||
|
||||
if (!m_stack.last().commands.is_empty()) {
|
||||
bool merged = m_stack.last().commands.last().merge_with(*command);
|
||||
if (merged)
|
||||
return;
|
||||
}
|
||||
|
||||
m_stack.last().commands.append(move(command));
|
||||
|
||||
if (on_state_change)
|
||||
|
||||
Reference in New Issue
Block a user