mirror of
https://github.com/RGBCube/serenity
synced 2025-06-29 03:42:07 +00:00
LibGUI: Split InsertTextCommand undo/redo based on whitespace
This commit is contained in:
parent
68aec687cf
commit
ee81c1b07a
1 changed files with 7 additions and 1 deletions
|
@ -764,16 +764,22 @@ bool InsertTextCommand::merge_with(GUI::Command const& other)
|
|||
{
|
||||
if (!is<InsertTextCommand>(other))
|
||||
return false;
|
||||
auto& typed_other = static_cast<InsertTextCommand const&>(other);
|
||||
|
||||
auto const& typed_other = static_cast<InsertTextCommand const&>(other);
|
||||
if (typed_other.m_text.is_whitespace() && !m_text.is_whitespace())
|
||||
return false; // Skip if other is whitespace while this is not
|
||||
|
||||
if (m_range.end() != typed_other.m_range.start())
|
||||
return false;
|
||||
if (m_range.start().line() != m_range.end().line())
|
||||
return false;
|
||||
|
||||
StringBuilder builder(m_text.length() + typed_other.m_text.length());
|
||||
builder.append(m_text);
|
||||
builder.append(typed_other.m_text);
|
||||
m_text = builder.to_string();
|
||||
m_range.set_end(typed_other.m_range.end());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue