1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-28 22:22:41 +03:00

Fix compute_pos behaviour not to overflow by one line

Thanks to eraserhd for debugging this and proposing an initial fix.

Fixes #3414
Close #3418
This commit is contained in:
Maxime Coste 2020-03-20 20:31:09 +11:00
parent 5466f63eeb
commit 0506de8443

View File

@ -124,6 +124,7 @@ struct TerminalUI::Window::Line
void TerminalUI::Window::blit(Window& target)
{
kak_assert(pos.line + lines.size() <= target.lines.size());
auto target_line = target.lines.begin() + (size_t)pos.line;
for (auto& line : lines)
{
@ -131,7 +132,7 @@ 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;
++target_line;
}
}
@ -1030,10 +1031,10 @@ static DisplayCoord compute_pos(DisplayCoord anchor, DisplayCoord size,
if (not prefer_above)
{
pos = anchor + DisplayCoord{1_line};
if (pos.line + size.line > rect_end.line)
if (pos.line + size.line >= rect_end.line)
pos.line = max(rect.pos.line, anchor.line - size.line);
}
if (pos.column + size.column > rect_end.column)
if (pos.column + size.column >= rect_end.column)
pos.column = max(rect.pos.column, rect_end.column - size.column);
if (to_avoid.size != DisplayCoord{})