Skip to content

[feature] New Preference setting : Use case-insensitive sorting in lists #1401

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

Closed

Conversation

goran-w
Copy link
Contributor

@goran-w goran-w commented Jun 6, 2025

Whether to sort lists using case-sensitive or case-insensitive ordering is a (usually strong) matter of taste and conventions.

To satisfy both camps, this option can now be toggled as a (global) Preferences checkbox (on the Appearance tab). When toggling this option, a RefreshAll() is performed to directly update visible lists.

NOTE: This also affects the non-digit substrings in NumericSort.Compare(). Additionally, that method is now refactored to remove some redunant code.

Fixed a missing case of numeric sorting, for root items in the RevisionFileTreeNode tree (which were still using ordinal string.Compare() instead of the intended NumericSort.Compare()). This is related to issue #597 and commit 76a7a22 which added "numeric sorting for all trees". The issue is corrected by refactoring the node sorting into a separate method, to make sure sorting is done the same way in both of the call-sites.

To support sorting options in Local Changes (Unstaged / Staged) lists, the output list from QueryLocalChanges() is now sorted by Path (instead of relying "blindly" on the sorting done by Git). Also, WorkingCopy.IsChanged() is now simplified / optimized and will additionally react to changes in sorting order.

goran-w added 5 commits June 6, 2025 09:09
Commit 76a7a22 added "numeric sorting for all trees" (sourcegit-scm#597) but missed a case - for root items in RevisionFileTreeNode tree, which was still using ordinal string.Compare().
Fixed by refactoring the node sorting into a separate method, to make sure it's done the same way in both instances.
@goran-w goran-w changed the title Add new Preferences checkbox : Use case-insensitive sorting in lists [feature] New Preferences checkbox : Use case-insensitive sorting in lists Jun 11, 2025
@goran-w goran-w changed the title [feature] New Preferences checkbox : Use case-insensitive sorting in lists [feature] New Preference setting : Use case-insensitive sorting in lists Jun 11, 2025
@goran-w
Copy link
Contributor Author

goran-w commented Jun 11, 2025

@love-linger would you consider merging this PR? It's a bit frustrating to switch between SourceGit and other tools (like Windows Explorer 😬) that ignore case when sorting files... (SourceGit does a special "numerical sorting", for only certain lists, but does not support the much more basic sorting-option of optionally ignoring case.)

Personally, I find it harder to locate names in case-sensitive lists. For example, in the list below, bee is not located between Beat and Bell - I have to look through two "sections" of the list to find it...

Art
Beat
Bell
Boo
Cow
Deep
Early
Far
arty
bee
cee
dee
fee

(BTW, there's additionally a bug-fix for numerical sorting of root RevisionFileTreeNode items in the first commit of this PR.)

@love-linger
Copy link
Collaborator

I've pushed a commit that use case-insensitive sorting in all filesystem related trees/lists by default. I do not want to add too many configurations.

@goran-w
Copy link
Contributor Author

goran-w commented Jun 11, 2025

@love-linger Thanks! However, I just realized that Commit.ParseDecorators() should also use the (case-insensitive) NumericSort.Compare() method, when comparing names for decorators (of same Type) in the call to Decorators.Sort(), since that's how Branches and Tags are sorted elsewhere...

@love-linger
Copy link
Collaborator

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants