diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-02-02 16:50:23 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-03-20 13:45:47 +0100 |
commit | 2cbf469912ae0e40049d3827db0c21cdf17c5a79 (patch) | |
tree | 64f57b6a0aefea73c9a1c62b3a703089bdb436e0 /editor/editor_file_system.cpp | |
parent | fe01776f05b1787b28b4a270d53037a3c25f4ca2 (diff) | |
download | redot-engine-2cbf469912ae0e40049d3827db0c21cdf17c5a79.tar.gz |
Fix sorting of files/dirs in dialogs
Sorts leading `_` before other characters except `.`.
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r-- | editor/editor_file_system.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index ff42b82435..516b8f3d74 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -50,10 +50,6 @@ EditorFileSystem *EditorFileSystem::singleton = nullptr; //the name is the version, to keep compatibility with different versions of Godot #define CACHE_FILE_NAME "filesystem_cache8" -void EditorFileSystemDirectory::sort_files() { - files.sort_custom<FileInfoSort>(); -} - int EditorFileSystemDirectory::find_file_index(const String &p_file) const { for (int i = 0; i < files.size(); i++) { if (files[i]->file == p_file) { @@ -578,7 +574,7 @@ bool EditorFileSystem::_update_scan_actions() { case ItemAction::ACTION_DIR_ADD: { int idx = 0; for (int i = 0; i < ia.dir->subdirs.size(); i++) { - if (ia.new_dir->name.naturalnocasecmp_to(ia.dir->subdirs[i]->name) < 0) { + if (ia.new_dir->name.filenocasecmp_to(ia.dir->subdirs[i]->name) < 0) { break; } idx++; @@ -600,7 +596,7 @@ bool EditorFileSystem::_update_scan_actions() { case ItemAction::ACTION_FILE_ADD: { int idx = 0; for (int i = 0; i < ia.dir->files.size(); i++) { - if (ia.new_file->file.naturalnocasecmp_to(ia.dir->files[i]->file) < 0) { + if (ia.new_file->file.filenocasecmp_to(ia.dir->files[i]->file) < 0) { break; } idx++; @@ -810,8 +806,8 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc da->list_dir_end(); - dirs.sort_custom<NaturalNoCaseComparator>(); - files.sort_custom<NaturalNoCaseComparator>(); + dirs.sort_custom<FileNoCaseComparator>(); + files.sort_custom<FileNoCaseComparator>(); int total = dirs.size() + files.size(); int idx = 0; @@ -832,7 +828,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Ref<DirAc int idx2 = 0; for (int i = 0; i < p_dir->subdirs.size(); i++) { - if (efd->name.naturalnocasecmp_to(p_dir->subdirs[i]->name) < 0) { + if (efd->name.filenocasecmp_to(p_dir->subdirs[i]->name) < 0) { break; } idx2++; @@ -1409,7 +1405,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector int idx2 = 0; for (int j = 0; j < fs->get_subdir_count(); j++) { - if (efsd->name.naturalnocasecmp_to(fs->get_subdir(j)->get_name()) < 0) { + if (efsd->name.filenocasecmp_to(fs->get_subdir(j)->get_name()) < 0) { break; } idx2++; @@ -1766,7 +1762,7 @@ void EditorFileSystem::update_file(const String &p_file) { String file_name = p_file.get_file(); for (int i = 0; i < fs->files.size(); i++) { - if (p_file.naturalnocasecmp_to(fs->files[i]->file) < 0) { + if (p_file.filenocasecmp_to(fs->files[i]->file) < 0) { break; } idx++; |