From 2e6a4aea99781944aa8b184b6ae928299e3f2efd Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 8 Jun 2021 16:20:31 +0200 Subject: [PATCH] Allow more items in automatic width calculation for TextEdit completion Calculating the width for 100 items takes a millisecond in a debug build on an i7-6700K. It's likely that the editor can remain smooth even with 1,000 items, especially in a release build. --- scene/gui/text_edit.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index dbcf171e477..434c208980e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1590,8 +1590,9 @@ void TextEdit::_notification(int p_what) { int scroll_rectangle_width = get_constant("completion_scroll_width"); int width = 0; - // Compute max width of the panel based on the longest completion option - if (completion_options_size < 50) { + // Compute max width of the panel based on the longest completion option. + // Limit the number of results for automatic width calculation to avoid freezing while showing results. + if (completion_options_size < 1000) { for (int i = 0; i < completion_options_size; i++) { int line_width = MIN(cache.font->get_string_size(completion_options[i].display).x, cmax_width); if (line_width > width) { @@ -1599,6 +1600,7 @@ void TextEdit::_notification(int p_what) { } } } else { + // Fall back to predetermined width. width = cmax_width; }