Fix crash when displaying a menu on a too small terminal
The code could position the menu at a negative line leading to invalid array accesses.
This commit is contained in:
parent
76e5d11c8b
commit
cbd0dc571b
|
@ -26,6 +26,8 @@ using std::max;
|
|||
|
||||
void TerminalUI::Window::create(const DisplayCoord& p, const DisplayCoord& s)
|
||||
{
|
||||
kak_assert(p.line >= 0 and p.column >= 0);
|
||||
kak_assert(s.line >= 0 and s.column >= 0);
|
||||
pos = p;
|
||||
size = s;
|
||||
lines.resize((int)size.line);
|
||||
|
@ -1005,7 +1007,7 @@ void TerminalUI::menu_show(ConstArrayView<DisplayLine> items,
|
|||
}
|
||||
else if (not is_inline)
|
||||
line = m_status_on_top ? 1_line : m_dimensions.line - height;
|
||||
else if (line + height > m_dimensions.line)
|
||||
else if (line + height > m_dimensions.line and anchor.line >= height)
|
||||
line = anchor.line - height;
|
||||
|
||||
const auto width = is_search ? m_dimensions.column - m_dimensions.column / 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user