-
Notifications
You must be signed in to change notification settings - Fork 715
Don't use locale-aware sorting in completions #1668
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,11 @@ func HasSuffix(s string, suffix string, caseSensitive bool) bool { | |
} | ||
return strings.EqualFold(s[len(s)-len(suffix):], suffix) | ||
} | ||
|
||
func CompareStringsCaseInsensitiveThenSensitive(a, b string) Comparison { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do this instead of just insensitive entirely? Is insensitive not a total order or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. "Ab" and "ab" are going to be equal under case insensitive comparison, but we still want one of them to be consistently sorted before the other for the tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, it's concerning that our case insensitive sort isn't correct, then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it really depends on what you're using it for. If you're using it to, say, dedupe paths in a case insensitive FS, then "Ab" and "ab" should be equal. |
||
cmp := CompareStringsCaseInsensitive(a, b) | ||
if cmp != ComparisonEqual { | ||
return cmp | ||
} | ||
return CompareStringsCaseSensitive(a, b) | ||
} | ||
jakebailey marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
The compareStrings assignment is unnecessary since the function is only used twice. Consider calling stringutil.CompareStringsCaseInsensitiveThenSensitive directly in both places to reduce code complexity.
Copilot uses AI. Check for mistakes.