summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-17 12:23:15 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-17 12:23:15 +0100
commit03cc4c3f3b1144cf59ffac6cdd561922abd2bd25 (patch)
tree9f73a348938049dac2511d90080c6ec2d4e2461a /scene
parent1e2297f13a5bae633e720585bb5b11f5b247641a (diff)
parent530b1f3f7a6e95abd8f731c8ce2a8c53f2d9a969 (diff)
Merge pull request #70168 from Haydoggo/autocomplete-placement-fix
Fix autocomplete box placement
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/code_edit.cpp4
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);