1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-10-29 08:42:07 +00:00

Coalesce the current line into a single chunk when moving away from it.

This commit is contained in:
Andreas Kling 2018-12-04 13:38:42 +01:00
parent e02eca2a5e
commit efd5aae217
4 changed files with 20 additions and 0 deletions

View file

@ -172,6 +172,7 @@ void Editor::move_down()
{
if (m_cursor.line() >= max_line())
return;
coalesce_current_line();
m_cursor.move_by(1, 0);
if (m_cursor.column() > max_column())
m_cursor.set_column(max_column());
@ -179,10 +180,16 @@ void Editor::move_down()
update_scroll_position_if_needed();
}
void Editor::coalesce_current_line()
{
m_document->lines()[m_cursor.line()].coalesce();
}
void Editor::move_up()
{
if (m_cursor.line() == 0)
return;
coalesce_current_line();
m_cursor.move_by(-1, 0);
if (m_cursor.column() > max_column())
m_cursor.set_column(max_column());