diff options
author | Hayden Leete <haydenleete@gmail.com> | 2022-12-17 10:17:55 +1300 |
---|---|---|
committer | Hayden Leete <haydenleete@gmail.com> | 2022-12-17 12:33:29 +1300 |
commit | 530b1f3f7a6e95abd8f731c8ce2a8c53f2d9a969 (patch) | |
tree | 7ed04e9e8cc548e2a7943f1bd24040f3f4cb5206 /scene | |
parent | 15631e24f740872c2be7cf81dd252c38b4aa174e (diff) |
Fix autocomplete box placement
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/code_edit.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index f46daef127..3bb02ebf7f 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -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); |