-
Notifications
You must be signed in to change notification settings - Fork 29.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
New Sort Order Lexicographic Options setting for Explorer #97272
Conversation
@leilapearson thanks for creating this PR for discussion. The descriptoin of the @bpasero would like to hear what you think as well. |
I am having a hard time to understand the intent based on looking at the code and seeing how the setting is presented in the settings editor. Maybe we can first explain the intent and then work on the naming? Sorry if I was not reading through the linked issues but I think I am playing the role as a user that is seeing this for the first time and I would not have a clue what the new setting does. The one looks like it replaces the other, but not sure? |
I wholeheartedly agree it's important for users to be able to understand the settings. I'm sure there's some way we can name and describe things to be more clear. I actually think I improved the wording somewhat already compared to the first PR, but obviously not enough... The key words in the descriptions that I was hoping would help in this case were files and folders versus names... Here's an explanation of how the settings are currently proposed to work: Sort Order specifies the first level of comparison. It specifies how items should be grouped and sorted based on properties other than their names. In particular, it pays attention to the following properties:
Sort Order Option is the second level of comparison. Sort Order Option is all about the names:
So Sort Order says, first let's compare items using some non-name properties. Then Sort Order Option says, now that we've compared based on those properties - for items that are equal using that first level of comparison, let's go on and compare based on the item names. So... that's what the settings are meant for as they currently stand. The actual algorithm can be thought of like this:
In all cases, the algorithm returns as soon as it finds a difference. Sort Order provides limited control over steps 1 through 3. By limited control over steps 1 through 3, I mean you can't - for example - choose to sort Sort Order Option provides limited control over steps 4 and 5. By limited here I mean you can't combine unicode order with upper first or lower first. These would be logically valid things to offer, but it seem unlikely that users would want them. Unicode already groups upper first just because that is how characters happen to be ordered in unicode, and it would seem kind of weird to call something unicode order that wasn't entirely unicode order. Without Sort Order Option available (current master), Sort Order skips step 4 and is hardcoded to use option 5a. Not sure if any of this explanation helps for thinking about how to present things in the settings UI - but I thought I'd write it down. If nothing else, it clarifies things a bit more for me. Given all of this, any ideas on how to rework or improve on the proposed settings UI? I'm hoping its just a matter of better naming and description wording - but I'm open to anything. I'll see what I can come up with too... |
Some ideas for the setting name:
@isidorn maybe consult with Andre too who is usually very good in wording 👍 |
My vote goes to @weinand for potential setting name ideas. |
For me as a user But from reading through the issue, that seems not to be the intent. My take: And the new setting controls exactly this second level sorting. My recommendation:
|
@weinand thanks a lot for great feedback! |
I really like the subsection idea too! I'm wondering if it should possibly be |
Okay sure. Just thought I'd check. |
With the name decided, I guess the next step is to decide specifically what lexicographic options should be offered. My original proposal was this:
Thinking about it now though, I'm wondering if it might be better to always sort numbers numerically instead of alphabetically, which would make the options a bit simpler:
In this case A dictionary will sort numbers numerically - not by digit comparisons. The downside is, if there is some need to add a non-numeric lexicographic options in the future, then I think the naming of these options would be kind of difficult... For example I'm not sure that there will be a future need for this though so maybe it isn't something to worry about now. The primary uses of numbers in file names are probably for version numbers - where the numeric option is handy - and dates - where many people probably use leading zeros, but it can be handy if they don't. Originally I was swayed towards non-numeric sorts by a comment in the issue that stated that people will just use leading zeros and are used to that. And then I was more swayed by the fact that a normal locale sort doesn't enable the numeric option and you have to specifically turn it on. But thinking about it some more I'm leaning the other way. People who are used to adding leading zeros are probably used to unicode sort - and that option will be available. Does Windows sort numerically BTW? It looks like OSX sorts numerically inside file explorer but in unicode order in the terminal. Google drive sorts non-numerically. |
@leilapearson BTW, you might want to use the term "natural sort order" when referring to sorting of strings with embedded numbers. |
@weinand - yes... I actually did take a quick look at python's Of course python's See: https://natsort.readthedocs.io/en/master/howitworks.html#here-be-dragons-adding-locale-support |
Looks like somebody did create a javascript natsort so I guess that would potentially be an option: https://www.npmjs.com/package/natsort Not sure about performance or the need to handle so many cases, so I'm not proposing to adopt it now - but it's something to keep in mind I guess. |
I am all up for reducing the options to have 4 values. We can add more if users request it. |
Okay. Sounds good. I'll go ahead with those four options and update the pull request when it's ready. |
Great, thanks |
The new plan is for all locale-based comparisons to use the `numeric` collator option. The compare options will only differ by case grouping. Rename compareFileNamesNumeric to compareFileNamesMixed and rename compareFileExtensionsNumeric to compareFileExtensionsMixed.
Add options for controlling the lexicographic order of file and folder names in Explorer. Adds options to group names uppercase first, group names lowercase first, or sort using a unicode comparison instead of a locale-based comparison.
I've made the changes, but I ran into a couple of issues:
The error is below:
|
Forgot to mention that I did end-to-end test all my changes before the merge from master and everything looks good to me. I verified that the changes in the previous PR that fixed the edge cases were preserved. In this PR I renamed those compare functions and pulled their code out into helper functions for the new options to reuse. The new changes look to be working as intended too. The results can be seen here: https://docs.google.com/spreadsheets/d/1Kw1eES9o5fs3q3IXvthdwx12zqLOr37hLXVvc1Aa3rE/edit?usp=sharing |
@leilapearson thanks a lot. I just review the changes in the Explorer, and overall it looks very good.
So bottom line: changes in Explorer land look great. |
Thanks @isidorn. Helpful as always!
|
I heartily agree with @leidegre above statement. If I may say @isidorn, code hosting platforms like GitHub, GitLab and even BitBucket use uppercase first as the default preference for lexicographic. This cause Visual Studio Code to visually break repositories lexical order which is a no-no when it comes to a source code editor. |
Count me as another user who wants this -- it's quite useful for me in typescript where Uppercase files are types and lowercase files are methods. (I'm not sure why you're avoiding merging things that provide more options to users. If you're trying to keep the settings page from becoming too cluttered, that ship has sailed...) |
Count me as another user who wants this. I've been using capitalization to sort certain files (CMakeLists.txt, README, LICENSE, etc) before source code files for decades. With VS Code's current options, these files always get sorted into the middle of all my other files and it's very jarring and inconsistent with the other tools I use. |
This would be a great feature to have. In the projects I work with, there are usually 'meta files' that are capitalized or start with a capital (CHANGELOG, LICENCE, README, Makefile). By having an option to sort files in a case sensitive fashion they are visually separated from the actual source code in the explorer, making it easier to navigate through a project. Big thanks to @leilapearson for your effort to get this feature in! |
Just wanted to mention @isidorn that I'm still happy to work on this again if/when you are okay to consider it for merging. There definitely does seem to be some interest per the above comments. There has also been some discussion in other tickets about the idea of enabling non-numeric sort for a use case I hadn't really considered which was filenames with hex numbers in them. Those sort very oddly with numeric sort enabled, so we may want to reconsider the idea of non-numeric options for locale-based searches too. On the other hand, the unicode sort option may be enough meet the needs of those users. Since I don't work or write in any languages other than english I'm not sure how important a locale-based non-numeric option would be. |
@leilapearson thanks a lot for offering to work on this. |
Thanks @isidorn. I'll see what I can do to make it as clear and concise as possible. It's great to be able to contribute this feature! |
@isidorn I've merged the latest main into my fork and topic branch, resolved the conflicts, and tested the change. I haven't reviewed |
@isidorn I shaved a few lines off in |
Looks great. I did an initial review left minor comments and once you tackle them I can merge this. |
Thanks for the review @isidorn. I made one small change per your comments but I'm not sure about the other two. Please see my comments and let me know what you think. My testing was all done on macOS Catalina (10.15.7) - so if you can try this out on Windows and Linux that would be great! |
Great, thanks for tackling my comments. Than my last tiny comment I will try it out and if it works nicely I will merge this in. |
Thanks for the re-review @isidorn. Should be good to go now I think! |
Looks good to me, and works just fine on my machine. |
Thank-you for the reviews and great suggestions @isidorn. Glad to help. |
@leilapearson, @isidorn and @bpasero, I have tested it and it worked. Thank you for fixing it! |
FWIW I've tested this on a Ubuntu machine (code-insiders package version 1.57.0-1620624357) and this also works for me as expected. Thank you very much! |
Per @isidorn I'm opening this PR so we can discuss the approach to resolving requests to group file and folder names by case. A number of people have requested this functionality and these requests were consolidated into issue #27759.
My suggested approach is to add a new setting - which I've tentatively called Sort Order Option so that it will show up immediately beneath the existing Sort Order setting.
This PR demonstrates the UI and proposed wording for the setting. The new setting isn't hooked up to anything yet and just serves to show the descriptions for the new options and the overall approach.
The options themselves are trivial to implement once we agree on which options to offer and not offer, and on the best way to offer these options in the settings UI.
I'll update the PR with the full functionality once the approach is agreed.