mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
GTextEditor: Implement Shift+Delete using RemoveTextCommand
This commit is contained in:
parent
990042c8ec
commit
32be9941f4
1 changed files with 15 additions and 7 deletions
|
@ -804,13 +804,21 @@ void GTextEditor::delete_current_line()
|
||||||
if (has_selection())
|
if (has_selection())
|
||||||
return delete_selection();
|
return delete_selection();
|
||||||
|
|
||||||
document().remove_line(m_cursor.line());
|
GTextPosition start;
|
||||||
if (lines().is_empty())
|
GTextPosition end;
|
||||||
document().append_line(make<GTextDocumentLine>(document()));
|
if (m_cursor.line() == 0 && lines().size() == 1) {
|
||||||
m_cursor.set_column(0);
|
start = { 0, 0 };
|
||||||
|
end = { 0, line(0).length() };
|
||||||
|
} else if (m_cursor.line() == lines().size() - 1) {
|
||||||
|
start = { m_cursor.line() - 1, line(m_cursor.line()).length() };
|
||||||
|
end = { m_cursor.line(), line(m_cursor.line()).length() };
|
||||||
|
} else {
|
||||||
|
start = { m_cursor.line(), 0 };
|
||||||
|
end = { m_cursor.line() + 1, 0 };
|
||||||
|
}
|
||||||
|
|
||||||
update_content_size();
|
GTextRange erased_range(start, end);
|
||||||
update();
|
execute<RemoveTextCommand>(document().text_in_range(erased_range), erased_range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTextEditor::do_delete()
|
void GTextEditor::do_delete()
|
||||||
|
@ -1365,8 +1373,8 @@ void GTextEditor::document_did_insert_line(int line_index)
|
||||||
|
|
||||||
void GTextEditor::document_did_change()
|
void GTextEditor::document_did_change()
|
||||||
{
|
{
|
||||||
ensure_cursor_is_valid();
|
|
||||||
recompute_all_visual_lines();
|
recompute_all_visual_lines();
|
||||||
|
ensure_cursor_is_valid();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
undo_action().set_enabled(can_undo());
|
undo_action().set_enabled(can_undo());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue