-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Issue #4409: Incorrect sort order for untitled files #4524
Conversation
Thanks @TomMalbran You're so quick! I was about to suggest localeCompare with options argument. That is,
But localeCompare function with optional 2nd and 3rd arguments are not supported in all browsers. So we may need to check for browser support as in this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#Example:_Checking_for_support_for_locales_and_options_arguments example and use it only if we have the browser support (required for in-browser version of Brackets). |
I never knew that localeCompare could have more arguments. This works in Chrome, so it will work inside brackets, but will fail once we go to the browser. Maybe is ok to have the previous sorting in FireFox until this is supported by FireFox? I don't think it should take them too long to support it. I just checked in the debugger tools and using: |
@TomMalbran So I think we should switch to use options argument if it is supported by the browser, and keep using the original localeCompare with one argument for browsers like FireFox. |
@RaymondLim Actually I prefer to use the options in the localeCompare. Since is already implemented is better to use it. It is also a visual fix, nothing is really broken if we use the old option. We would still need to use it as I posted it, with undefined as the locale, so that is works for any locale and not just Enlgish. Since JavaScript ditches the extra parameters passed to a function, it works in FireFox passing the options. It just returns the result as if there wasn't options. We can just use he function with the options for every browser. |
I totally agree with you to use undefined for locale argument. I used "en" just for a quick testing and not sure that it can take undefined when I posted my comment. |
The second and third argument are optional, so when they are not given, they get the value of undefined. I also tested it and it works. |
@RaymondLim updated the fix using the options parameter. |
Your changes look good! But we still need two more changes.
|
|
You're right that we still need your |
Looks good. Merging. |
Issue #4409: Incorrect sort order for untitled files
Great. Thanks. |
This PR fixes the second issue mentioned in #4409 by comparing the numbers when the filenames are the same for the exception of the number at the end of the string.
@RaymondLim I was able to get it done today.