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

GTextEditor: Support splitting lines at the cursor with the Return key.

This commit is contained in:
Andreas Kling 2019-03-07 16:49:04 +01:00
parent a64b71fb3d
commit 43d56b6f3a
3 changed files with 30 additions and 6 deletions

View file

@ -252,12 +252,22 @@ public:
void resize(ssize_t new_size)
{
ASSERT(new_size >= size());
if (!new_size)
if (new_size == size())
return;
ensure_capacity(new_size);
for (ssize_t i = size(); i < new_size; ++i)
new (m_impl->slot(i)) T;
if (!new_size) {
clear();
return;
}
if (new_size > size()) {
ensure_capacity(new_size);
for (ssize_t i = size(); i < new_size; ++i)
new (m_impl->slot(i)) T;
} else {
for (int i = new_size; i < size(); ++i)
m_impl->at(i).~T();
}
m_impl->m_size = new_size;
}