Fix FileDialog file name autocompletion with filters

Fixes #38195.

(cherry picked from commit 446f1b7052)
This commit is contained in:
Thakee Nathees 2020-04-28 19:33:46 +05:30 committed by Rémi Verschelde
parent 7d8adb2dc5
commit da626d8922
2 changed files with 8 additions and 3 deletions

View file

@ -704,9 +704,9 @@ void EditorFileDialog::update_file_name() {
String base_name = file_str.get_basename(); String base_name = file_str.get_basename();
Vector<String> filter_substr = filter_str.split(";"); Vector<String> filter_substr = filter_str.split(";");
if (filter_substr.size() >= 2) { 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 { } 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); file->set_text(file_str);
} }

View file

@ -396,7 +396,12 @@ void FileDialog::update_file_name() {
String filter_str = filters[idx]; String filter_str = filters[idx];
String file_str = file->get_text(); String file_str = file->get_text();
String base_name = file_str.get_basename(); String base_name = file_str.get_basename();
file_str = base_name + "." + filter_str.strip_edges().to_lower(); Vector<String> 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); file->set_text(file_str);
} }
} }