-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sorting of files/dirs in dialogs #87874
Conversation
b35c446
to
74813c6
Compare
This was originally intentional and done in: Going with restoring the useful sorting here and unifying everything in this direction instead, the original sorting just used plain string comparisons, this now uses the new comparison setup, originally Keeping the case insensitive sorting that was already used |
74813c6
to
94aeb1d
Compare
}; | ||
|
||
void sort_files(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this as it's not used anywhere that I could find, will restore if necessary
if (this_str && that_str) { | ||
while (*this_str == '.' || *that_str == '.') { | ||
if (*this_str++ != '.') { | ||
static _FORCE_INLINE_ signed char naturalcasecmp_to_base(const char32_t *p_this_str, const char32_t *p_that_str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As both file
and natural
sorting use these I merged them to avoid code duplication
94aeb1d
to
890676c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing against this by the way, if it's the one way to fix this. I am not convinced on exposing this, since I can't recall anyone explicitly desiring it, but I am not severely opposed to it, either.
Maybe my pure approval will attract the rest of the herd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and seems to work fine (tested using the filesystem dialog). I think it makes sense to expose this even though nobody explicitly asked for it, because this is the behavior which was present in Godot 3.x.
Will fixup and squash :) |
665434c
to
21271ca
Compare
Sorts leading `_` before other characters except `.`.
21271ca
to
2cbf469
Compare
Fix sorting of files/dirs in dialogs
06abc86
Thanks! |
Thank you! |
Sorts leading
_
before all except.
.Optionally bound to scripting
Optionally added to
FileDialog
but can omit that if it's compatibility breakingAdded to a few places, think I've gotten all the places in the editor that handles files by ordering
The exact ordering can be further discussed, i.e. sorting
_
before just alphanumerics, etc., but keeping it relatively simple hereBased on how sorting is done in Windows file explorer (though in Powershell it sorts
_
after uppercase, so it depends, but I think it makes sense based on the reasons in the issue below)