From 08118b1456a7f623b08c61cf42c157f3a6151da3 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Fri, 16 Jun 2023 06:51:02 +0200 Subject: [PATCH] Only display 15 nodes in the Recent section of the Create New Node dialog This prevents the history size from becoming too large, which made it less useful. This also fixes an off-by-one error in the completion scoring algorithm. --- editor/create_dialog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 6d345a1d8476..8b71d7586ff6 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -370,7 +370,8 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co // Look through at most 5 recent items bool in_recent = false; - for (int i = 0; i < MIN(5, recent->get_item_count()); i++) { + constexpr int RECENT_COMPLETION_SIZE = 5; + for (int i = 0; i < MIN(RECENT_COMPLETION_SIZE - 1, recent->get_item_count()); i++) { if (recent->get_item_text(i) == p_type) { in_recent = true; break; @@ -406,7 +407,8 @@ void CreateDialog::_confirmed() { if (f.is_valid()) { f->store_line(selected_item); - for (int i = 0; i < MIN(32, recent->get_item_count()); i++) { + constexpr int RECENT_HISTORY_SIZE = 15; + for (int i = 0; i < MIN(RECENT_HISTORY_SIZE - 1, recent->get_item_count()); i++) { if (recent->get_item_text(i) != selected_item) { f->store_line(recent->get_item_text(i)); }