summaryrefslogtreecommitdiffstats
path: root/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r--editor/filesystem_dock.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 03e4dffc70..c5feb71c9e 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1729,12 +1729,12 @@ void FileSystemDock::_folder_removed(String p_folder) {
void FileSystemDock::_rename_operation_confirm() {
String new_name;
- TreeItem *s = tree->get_selected();
- int col_index = tree->get_selected_column();
+ TreeItem *ti = tree->get_edited();
+ int col_index = tree->get_edited_column();
- if (tree->has_focus()) {
- new_name = s->get_text(col_index).strip_edges();
- } else if (files->has_focus()) {
+ if (ti) {
+ new_name = ti->get_text(col_index).strip_edges();
+ } else {
new_name = files->get_edit_text().strip_edges();
}
String old_name = to_rename.is_file ? to_rename.path.get_file() : to_rename.path.left(-1).get_file();
@@ -1757,10 +1757,10 @@ void FileSystemDock::_rename_operation_confirm() {
}
// Restore original name.
- if (rename_error && tree->has_focus()) {
- s->set_text(col_index, old_name);
- return;
- } else if (rename_error && files->has_focus()) {
+ if (rename_error) {
+ if (ti) {
+ ti->set_text(col_index, old_name);
+ }
return;
}
@@ -1776,14 +1776,14 @@ void FileSystemDock::_rename_operation_confirm() {
// Present a more user friendly warning for name conflict.
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
-#if defined(WINDOWS_ENABLED)
- // Workaround case insensitivity on Windows.
- if ((da->file_exists(new_path) || da->dir_exists(new_path)) && new_path.to_lower() != old_path.to_lower()) {
-#else
- if (da->file_exists(new_path) || da->dir_exists(new_path)) {
-#endif
+
+ bool new_exist = (da->file_exists(new_path) || da->dir_exists(new_path));
+ if (!da->is_case_sensitive(new_path.get_base_dir())) {
+ new_exist = new_exist && (new_path.to_lower() != old_path.to_lower());
+ }
+ if (new_exist) {
EditorNode::get_singleton()->show_warning(TTR("A file or folder with this name already exists."));
- s->set_text(col_index, old_name);
+ ti->set_text(col_index, old_name);
return;
}
@@ -1803,7 +1803,7 @@ void FileSystemDock::_rename_operation_confirm() {
EditorSceneTabs::get_singleton()->set_current_tab(current_tab);
- if (tree->has_focus()) {
+ if (ti) {
current_path = new_path;
current_path_line_edit->set_text(current_path);
}
@@ -2004,13 +2004,13 @@ void FileSystemDock::_before_move(HashMap<String, ResourceUID::ID> &r_uids, Vect
EditorNode::get_singleton()->save_scene_list(r_file_owners);
}
-Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion) const {
+Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion, bool p_include_unselected_cursor) const {
// Build a list of selected items with the active one at the first position.
Vector<String> selected_strings;
TreeItem *favorites_item = tree->get_root()->get_first_child();
TreeItem *cursor_item = tree->get_selected();
- if (cursor_item && cursor_item->is_selected(0) && cursor_item != favorites_item) {
+ if (cursor_item && (p_include_unselected_cursor || cursor_item->is_selected(0)) && cursor_item != favorites_item) {
selected_strings.push_back(cursor_item->get_metadata(0));
}
@@ -2059,6 +2059,10 @@ void FileSystemDock::_tree_rmb_option(int p_option) {
tree->get_selected()->set_collapsed_recursive(p_option == FOLDER_COLLAPSE_ALL);
}
} break;
+ case FILE_RENAME: {
+ selected_strings = _tree_get_selected(false, true);
+ [[fallthrough]];
+ }
default: {
_file_option(p_option, selected_strings);
} break;