Fix completion popup placement and adjust lines to available space#112991
Conversation
3945e23 to
fac8555
Compare
|
If you're able to get that, screenshots of before/after could be useful for a quick assessment of the placement change. |
Updated the PR description with before/after videos. In the before clip, the completion window gets cut off, but in the after clip it correctly positions itself above the line and line no is also reduced to fit. You can observe the issue on desktop editor too, just minimize the script editor height. Screencast_20251121_001128.webm |
fac8555 to
8b01363
Compare
|
The completion popup should be changed to an actual popup so it can show outside of the CodeEdit, at some point. |
There was a problem hiding this comment.
I've included some print_line functions to examine their impact on the Unit Tests.
./tests/scene/test_code_edit.h:4164: ERROR: CHECK( code_edit->get_code_completion_selected_index() == 2 ) is NOT correct!
values: CHECK( -1 == 2 )
total_height: 81
code_edit->get_line_height(): 27
81 / 27 = 3 lines
Your PR reduces the number of lines from 3 to 2.
// Reduce the line count and recalculate heights to better fit the completion popup.
...
total_height = theme_cache.code_completion_style->get_minimum_size().y + code_completion_rect.size.height;total_height: 54
54 / 27 = 2 lines
Possible fix: no longer check the 3rd line, but the 2nd.
https://github.com/godotengine/godot/blob/master/tests/scene/test_code_edit.h#L4160-L4170
/* Single click selects. */
caret_pos.y += code_edit->get_line_height();
SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(caret_pos, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
CHECK(code_edit->get_code_completion_selected_index() == 1);
/* Double click inserts. */
SEND_GUI_DOUBLE_CLICK(caret_pos, Key::NONE);
CHECK(code_edit->get_code_completion_selected_index() == -1);
CHECK(code_edit->get_line(0) == "item_1");
Alex2782
left a comment
There was a problem hiding this comment.
Tested on MacOS, looks good to me.
Screen-2025-11-25-010711.mp4
2ed16e8 to
ef5fbe8
Compare
ef5fbe8 to
834dfcb
Compare
|
Thanks! |
|
This kindof fixes #38560 (which is very nice, thanks!), but I would kindly request again for the AutoComplete popup to be able to extend beyond the CodeEdits size. Would be super useful to allow small code edits to use autocompletion, which we could use in Dialogic (as proposed here godotengine/godot-proposals#7162) and as you can see above this could even be useful for the script editor on small devices. As said above:
Thank you very much for all your work already 🙏😊 |
Previously, when the code completion popup could not fully fit either above or below the current line, the editor always defaulted to drawing it below. This caused the popup to be partially cut off in small editor windows.
This PR improves that behavior:
Before
Screenrecorder-2025-11-20-23-24-02-268.mp4
After
Screenrecorder-2025-11-20-23-18-38-631.mp4