mirror of
https://github.com/godotengine/godot
synced 2024-09-05 05:58:29 +00:00
Fix file rename crash after toggling split mode.
This commit is contained in:
parent
5dc10b5aa5
commit
7fea0cef4c
|
@ -88,6 +88,7 @@ void FileSystemList::_line_editor_submit(String p_text) {
|
|||
bool FileSystemList::edit_selected() {
|
||||
ERR_FAIL_COND_V_MSG(!is_anything_selected(), false, "No item selected.");
|
||||
int s = get_current();
|
||||
ERR_FAIL_COND_V_MSG(s < 0, false, "No current item selected.");
|
||||
ensure_current_is_visible();
|
||||
|
||||
Rect2 rect;
|
||||
|
@ -907,12 +908,13 @@ void FileSystemDock::_sort_file_info_list(List<FileSystemDock::FileInfo> &r_file
|
|||
}
|
||||
|
||||
void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
||||
// Register the previously selected items.
|
||||
HashSet<String> cselection;
|
||||
// Register the previously current and selected items.
|
||||
HashSet<String> previous_selection;
|
||||
HashSet<int> valid_selection;
|
||||
if (p_keep_selection) {
|
||||
for (int i = 0; i < files->get_item_count(); i++) {
|
||||
if (files->is_selected(i)) {
|
||||
cselection.insert(files->get_item_text(i));
|
||||
previous_selection.insert(files->get_item_text(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1068,8 +1070,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
Color this_folder_color = has_custom_color ? folder_colors[assigned_folder_colors[dpath]] : inherited_folder_color;
|
||||
files->set_item_icon_modulate(-1, editor_is_dark_theme ? this_folder_color : this_folder_color * 1.75);
|
||||
|
||||
if (cselection.has(dname)) {
|
||||
if (previous_selection.has(dname)) {
|
||||
files->select(files->get_item_count() - 1, false);
|
||||
valid_selection.insert(files->get_item_count() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1142,8 +1145,9 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
}
|
||||
|
||||
// Select the items.
|
||||
if (cselection.has(fname)) {
|
||||
if (previous_selection.has(fname)) {
|
||||
files->select(item_index, false);
|
||||
valid_selection.insert(item_index);
|
||||
}
|
||||
|
||||
if (!p_keep_selection && !file.is_empty() && fname == file) {
|
||||
|
@ -1159,6 +1163,11 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
|||
}
|
||||
files->set_item_tooltip(item_index, tooltip);
|
||||
}
|
||||
|
||||
// If we only have any selected items retained, we need to update the current idx.
|
||||
if (!valid_selection.is_empty()) {
|
||||
files->set_current(*valid_selection.begin());
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_select_file(const String &p_path, bool p_select_in_favorites) {
|
||||
|
|
Loading…
Reference in a new issue