Skip to content
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

Unconventional and counterintuitive filename sorting: "." comes after all other characters, should come before #199676

Closed
php4fan opened this issue Nov 30, 2023 · 10 comments
Assignees

Comments

@php4fan
Copy link

php4fan commented Nov 30, 2023

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.84.2
  • OS Version: Manjaro linux

Steps to Reproduce:

  1. Open a project that has files with these names:
functions.php
functions_admin.php
functions_user.php
  1. Look at the list of files in the left panel ("Explorer" I think it's called)

Expected behavior

They should be sorted in this order:

functions.php
functions_admin.php
functions_user.php

This is the prevailing convention everywhere, it has always been, and for good reason, because it's the only right one. If not in general, certainly for file names.
The dot is commonly conventionally used to separate file name from file extension. Therefore, xxxxx followed by a dot means a filename xxxxx followed by nothing. And nothing intuitively comes before anything. That's why the dot usually comes before any other (normal) character at least when sorting file names.
Again, not only is this the way sorting filenames has always been done and is done everywhere, it is the right way of doing it because it makes sense.

Observed behavior

They are sorted like this:

functions_admin.php
functions_user.php
functions.php

i.e. the dot (".") comes after any other character.
This is confusing, counterintuitive, illogical, and contrary to prevailing and long-standing conventions. There's no justification for such behavior.

I have seen the same issue before in other pieces of software in Linux (I think starting recently), so VSCode is not alone, but that doesn't make it any less wrong, and it's the exception, not the norm.

@php4fan php4fan changed the title Wrong filename sorting: "." comes after every other character, should come before Unconventional and counterintuitive filename sorting: "." comes after all other characters, should come before Nov 30, 2023
@lramos15
Copy link
Member

Try changing your sort options to unicode
image

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

That fixes the dot but it messes up the underscore.
With "unicode", the underscore apparently comes after all letters; so with unicode now foobar will come before foo_bar which is also counterintuitive and contrary to prevailing conventions.

@lramos15
Copy link
Member

That matches macOS explorer at least. I think convention varies
image

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

Yes, MacOS is crap when it comes to this kind of things. Apple usually goes against conventions by design.

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

Either way, having to choose between "dot comes before letters but underscore comes after" and viceversa makes no sense. Nor does the fact that that choice goes together with "default" (whatever that means) vs Unicode.

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

And what if I wanted to choose Uppercase first or Lowercase first. What would the behavior of underscore and dot be in those cases? Overall the choice of sorting is utter nonsense.

@lramos15
Copy link
Member

Hmmm this is with unicode

image

And here's the way the sort works

/** Compares full filenames by unicode value. */
export function compareFileNamesUnicode(one: string | null, other: string | null) {
one = one || '';
other = other || '';
if (one === other) {
return 0;
}
return one < other ? -1 : 1;
}

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

Ok, it seems unicode groups uppercase first, which renders it useless unless you are one of the few people who would want uppercase first.

With the files I have, the one I was looking for with an underscore was at the end rather than at the beginning and I mistakenly attributed that to the underscore.

This is even worse.

So the choice is between:

default: "" < "a" < "." => crap
unicode: all uppercase < all lowercase => crap
upper: crap by definition unless that's what you want (who knows how it treats "
" and "."
lower: same

@lramos15
Copy link
Member

Maybe keep an eye on #27286 which tracks the idea of being able to provide a custom sort order

@php4fan
Copy link
Author

php4fan commented Nov 30, 2023

These three choices should be independent of each other:

  • lowercase first vs upper case vs mixed
  • unicode or not (whatever "not unicode" is)
  • special characters (e.g. "_" and ".") before or after letters and numbers

Probably the last one should be even more granular (or not exist at all and be all before including dot), because even if someone wanted characters like "_" and "-" to come after letters, it may still be convenient for "." to come before, because it separates the file name from the extension (i.e. you would want "xxxx" to come before "xxxx + anything", before the extension).

@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants