mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibGUI: Extract repeated code for populating TextEditor per-line data
This commit is contained in:
parent
ba43ee4046
commit
03571b1fa9
2 changed files with 13 additions and 7 deletions
|
@ -2203,11 +2203,19 @@ void TextEditor::document_did_update_undo_stack()
|
|||
on_modified_change(document().is_modified());
|
||||
}
|
||||
|
||||
void TextEditor::document_did_set_text(AllowCallback allow_callback)
|
||||
void TextEditor::populate_line_data()
|
||||
{
|
||||
m_line_visual_data.clear();
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i)
|
||||
m_line_visual_data.append(make<LineVisualData>());
|
||||
m_line_visual_data.ensure_capacity(m_document->line_count());
|
||||
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i) {
|
||||
m_line_visual_data.unchecked_append(make<LineVisualData>());
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditor::document_did_set_text(AllowCallback allow_callback)
|
||||
{
|
||||
populate_line_data();
|
||||
document_did_change(allow_callback);
|
||||
}
|
||||
|
||||
|
@ -2233,10 +2241,7 @@ void TextEditor::set_document(TextDocument& document)
|
|||
if (m_document)
|
||||
m_document->unregister_client(*this);
|
||||
m_document = document;
|
||||
m_line_visual_data.clear();
|
||||
for (size_t i = 0; i < m_document->line_count(); ++i) {
|
||||
m_line_visual_data.append(make<LineVisualData>());
|
||||
}
|
||||
populate_line_data();
|
||||
set_cursor(0, 0);
|
||||
if (has_selection())
|
||||
m_selection.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue