diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index 41218992b1c..da5ee7c923d 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -521,18 +521,28 @@ void QuickOpenResultContainer::update_results() { } void QuickOpenResultContainer::_use_default_candidates() { + HashSet existing_paths; Vector *history = _get_history(); if (history) { candidates.append_array(*history); + for (const QuickOpenResultCandidate &candi : *history) { + existing_paths.insert(candi.file_path); + } } + int i = candidates.size(); + candidates.resize(MIN(max_total_results, filepaths.size())); + QuickOpenResultCandidate *candidates_w = candidates.ptrw(); int count = candidates.size(); - int i = 0; + for (const String &filepath : filepaths) { if (i >= count) { break; } - _setup_candidate(candidates.write[i++], filepath); + if (existing_paths.has(filepath)) { + continue; + } + _setup_candidate(candidates_w[i++], filepath); } }