Fix autocomplete box placement

This commit is contained in:
Hayden Leete
2022-12-17 10:17:55 +13:00
parent 15631e24f7
commit 530b1f3f7a
2 changed files with 5 additions and 2 deletions

View File

@@ -115,7 +115,9 @@ void CodeEdit::_notification(int p_what) {
const Point2 caret_pos = get_caret_draw_pos();
const int total_height = csb->get_minimum_size().y + code_completion_rect.size.height;
if (caret_pos.y + row_height + total_height > get_size().height) {
const bool can_fit_completion_above = (caret_pos.y - row_height > total_height);
const bool can_fit_completion_below = (caret_pos.y + row_height + total_height <= get_size().height);
if (!can_fit_completion_below && can_fit_completion_above) {
code_completion_rect.position.y = (caret_pos.y - total_height - row_height) + line_spacing;
} else {
code_completion_rect.position.y = caret_pos.y + (line_spacing / 2.0f);