diff --git a/src/core/BufferView.cc b/src/core/BufferView.cc index 99e8ec1..7e42296 100644 --- a/src/core/BufferView.cc +++ b/src/core/BufferView.cc @@ -36,6 +36,12 @@ BufferView::Iterator BufferView::vert_iter() void BufferView::update() { + /* Calculate number of rows in the cursor line and update cursor row offset + * and cursor column values. */ + auto start_of_line = std::make_shared(*m_iterator); + start_of_line->go_start_of_line(); + int rows_in_cursor_line = calculate_rows_in_cursor_line(start_of_line); + /* Update the cursor screen row in case the cursor position changed. */ m_cursor_screen_row = determine_new_cursor_screen_row(); @@ -43,9 +49,6 @@ void BufferView::update() * available buffer contents above and below the current line, and scroll * offset. */ std::list>> backward_lines; - auto start_of_line = std::make_shared(*m_iterator); - start_of_line->go_start_of_line(); - int rows_in_cursor_line = calculate_rows_in_cursor_line(start_of_line); int so = effective_scroll_offset(); int rows_above = screen_rows_above_line(start_of_line, backward_lines) + m_cursor_row_offset; int rows_below = screen_rows_below_line(start_of_line) + std::max(0, rows_in_cursor_line - m_cursor_row_offset - 1); @@ -115,7 +118,6 @@ int BufferView::determine_new_cursor_screen_row() { if (screen_line.line->line() == m_iterator->line()) { - calculate_rows_in_cursor_line(screen_line.line); return screen_line.row_offset + m_cursor_row_offset; } }