mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:45:11 +00:00
LibGUI: Fix wrong cursor position after undoing RemoveTextCommand
When you undo some forward delete shortcuts like <Del> or <Ctrl-Del>, the cursor will be put at the end of the text deleted, while the right position should be the start of those text.
This commit is contained in:
parent
b78622ddf7
commit
200a4a00dd
3 changed files with 19 additions and 17 deletions
|
@ -963,10 +963,11 @@ void InsertTextCommand::undo()
|
|||
m_document.set_all_cursors(m_range.start());
|
||||
}
|
||||
|
||||
RemoveTextCommand::RemoveTextCommand(TextDocument& document, DeprecatedString const& text, TextRange const& range)
|
||||
RemoveTextCommand::RemoveTextCommand(TextDocument& document, DeprecatedString const& text, TextRange const& range, TextPosition const& original_cursor_position)
|
||||
: TextDocumentUndoCommand(document)
|
||||
, m_text(text)
|
||||
, m_range(range)
|
||||
, m_original_cursor_position(original_cursor_position)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1006,8 +1007,8 @@ void RemoveTextCommand::redo()
|
|||
|
||||
void RemoveTextCommand::undo()
|
||||
{
|
||||
auto new_cursor = m_document.insert_at(m_range.start(), m_text);
|
||||
m_document.set_all_cursors(new_cursor);
|
||||
m_document.insert_at(m_range.start(), m_text);
|
||||
m_document.set_all_cursors(m_original_cursor_position);
|
||||
}
|
||||
|
||||
InsertLineCommand::InsertLineCommand(TextDocument& document, TextPosition cursor, DeprecatedString&& text, InsertPosition pos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue