Tolerate bliting window that overflow the target

Although we try to avoid those, ensuring it never happens is tricky,
and tolerating them avoids the crash.

Fixes 
This commit is contained in:
Maxime Coste 2020-05-25 22:43:40 +10:00
parent 89e0b4b830
commit cd613da050

View File

@ -145,7 +145,7 @@ struct TerminalUI::Window::Line
void TerminalUI::Window::blit(Window& target)
{
kak_assert(pos.line + lines.size() <= target.lines.size());
kak_assert(pos.line < target.lines.size());
auto target_line = target.lines.begin() + (size_t)pos.line;
for (auto& line : lines)
{
@ -153,7 +153,8 @@ void TerminalUI::Window::blit(Window& target)
target_line->resize(target.size.column);
target_line->atoms.insert(target_line->erase_range(pos.column, size.column),
line.atoms.begin(), line.atoms.end());
++target_line;
if (++target_line == target.lines.end())
break;
}
}