re-calculate cursor column for all cursors on any insertion

This commit is contained in:
Josh Holtrop 2016-10-29 15:05:43 -04:00
parent 35ff48c38f
commit a268c673fa
2 changed files with 6 additions and 1 deletions

View File

@ -497,6 +497,11 @@ void PieceTable::insert_code_point(uint32_t code_point)
uint8_t bytes = Encoding::encode(code_point, encoding, &m_append_buffer[m_append_buffer_index]);
m_inserting_piece->length += bytes;
m_append_buffer_index += bytes;
for (auto cursor : m_cursors)
{
cursor->calculate_column();
}
}
}

View File

@ -135,6 +135,7 @@ public:
}
void warp_to_inserted_piece(Piece * piece);
void warp_to_beginning_of_piece(Piece * piece);
void calculate_column();
protected:
bool is_start_of_line();
@ -142,7 +143,6 @@ public:
Piece * prev_line() const;
Piece * next_line() const;
void init_column();
void calculate_column();
void forward_to_column(uint32_t c);
};