summaryrefslogtreecommitdiffstats
path: root/editor/filesystem_dock.cpp
diff options
context:
space:
mode:
authorArtemy Fedotov <catlovescpp@gmail.com>2024-07-24 20:01:11 +0400
committerRémi Verschelde <rverschelde@gmail.com>2024-09-16 17:03:50 +0200
commit41682201696b29817abc935ca88edfbf9b60ccab (patch)
treeb9fb4011d8e2b363bda1cd27b8e780cf06e30c2e /editor/filesystem_dock.cpp
parentd8c13f88ed500b962a95c837929cec6571a8d62c (diff)
downloadredot-engine-41682201696b29817abc935ca88edfbf9b60ccab.tar.gz
Fix `EditorInterface.get_selected_paths()` working incorrectly when FileSystemDock is in split mode
(cherry picked from commit b55e97cd852d3bc8b0dd101f932beb306ac63ae1)
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r--editor/filesystem_dock.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index d4bd97a393..59351a8efc 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -685,7 +685,15 @@ void FileSystemDock::_tree_multi_selected(Object *p_item, int p_column, bool p_s
}
Vector<String> FileSystemDock::get_selected_paths() const {
- return _tree_get_selected(false);
+ if (display_mode == DISPLAY_MODE_TREE_ONLY) {
+ return _tree_get_selected(false);
+ } else {
+ Vector<String> selected = _file_list_get_selected();
+ if (selected.is_empty()) {
+ selected.push_back(get_current_directory());
+ }
+ return selected;
+ }
}
String FileSystemDock::get_current_path() const {
@@ -2049,6 +2057,15 @@ Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion, bo
return selected_strings;
}
+Vector<String> FileSystemDock::_file_list_get_selected() const {
+ Vector<String> selected;
+
+ for (int idx : files->get_selected_items()) {
+ selected.push_back(files->get_item_metadata(idx));
+ }
+ return selected;
+}
+
Vector<String> FileSystemDock::_remove_self_included_paths(Vector<String> selected_strings) {
// Remove paths or files that are included into another.
if (selected_strings.size() > 1) {