mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +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
Notes:
sideshowbarker
2024-07-16 22:17:03 +09:00
Author: https://github.com/lixk28
Commit: 200a4a00dd
Pull-request: https://github.com/SerenityOS/serenity/pull/18900
Reviewed-by: https://github.com/gmta ✅
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