From da626d89224e4fafbbec234c47bd0a1e7cac1d90 Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Tue, 28 Apr 2020 19:33:46 +0530 Subject: [PATCH] Fix FileDialog file name autocompletion with filters Fixes #38195. (cherry picked from commit 446f1b70522d86b9afe93b6543028cbab60ffb61) --- editor/editor_file_dialog.cpp | 4 ++-- scene/gui/file_dialog.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 4c7517028bc..1148ff062a7 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -704,9 +704,9 @@ void EditorFileDialog::update_file_name() { String base_name = file_str.get_basename(); Vector filter_substr = filter_str.split(";"); if (filter_substr.size() >= 2) { - file_str = base_name + "." + filter_substr[0].strip_edges().lstrip("*.").to_lower(); + file_str = base_name + "." + filter_substr[0].strip_edges().get_extension().to_lower(); } else { - file_str = base_name + "." + filter_str.get_extension().strip_edges().to_lower(); + file_str = base_name + "." + filter_str.strip_edges().get_extension().to_lower(); } file->set_text(file_str); } diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 2f6ccc6538a..a74e6034022 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -396,7 +396,12 @@ void FileDialog::update_file_name() { String filter_str = filters[idx]; String file_str = file->get_text(); String base_name = file_str.get_basename(); - file_str = base_name + "." + filter_str.strip_edges().to_lower(); + Vector filter_substr = filter_str.split(";"); + if (filter_substr.size() >= 2) { + file_str = base_name + "." + filter_substr[0].strip_edges().get_extension().to_lower(); + } else { + file_str = base_name + "." + filter_str.strip_edges().get_extension().to_lower(); + } file->set_text(file_str); } }