mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Switch to unicase's to_folded_case (#14255)
# Description Switch `to_folded_case` to a proper case fold instead of `str::to_lowercase` now that unicase exposes its `to_folded_case` method. Rel: #10884, https://github.com/seanmonstar/unicase/issues/61 # User-Facing Changes Case insensitive sorts now do proper case folding. Old behavior: ```nushell [dreißig DREISSIG] | sort -i # => ╭───┬──────────╮ # => │ 0 │ DREISSIG │ # => │ 1 │ dreißig │ # => ╰───┴──────────╯ ``` New behavior: ```nushell [dreißig DREISSIG] | sort -i # => ╭───┬──────────╮ # => │ 0 │ dreißig │ # => │ 1 │ DREISSIG │ # => ╰───┴──────────╯ ```
This commit is contained in:
parent
62198a29c2
commit
7a7df3e635
@ -9,11 +9,6 @@ pub trait IgnoreCaseExt {
|
||||
/// language-invariant and consistent. Case folded text should be used
|
||||
/// solely for processing and generally should not be stored or displayed.
|
||||
///
|
||||
/// Note: this method might only do [`str::to_lowercase`] instead of a
|
||||
/// full case fold, depending on how Nu is compiled. You should still
|
||||
/// prefer using this method for generating case-insensitive strings,
|
||||
/// though, as it expresses intent much better than `to_lowercase`.
|
||||
///
|
||||
/// [case folded]: <https://unicode.org/faq/casemap_charprop.html#2>
|
||||
fn to_folded_case(&self) -> String;
|
||||
|
||||
@ -40,9 +35,7 @@ pub trait IgnoreCaseExt {
|
||||
|
||||
impl IgnoreCaseExt for str {
|
||||
fn to_folded_case(&self) -> String {
|
||||
// we only do to_lowercase, as unicase doesn't expose its case fold yet
|
||||
// (seanmonstar/unicase#61) and we don't want to pull in another table
|
||||
self.to_lowercase()
|
||||
UniCase::new(self).to_folded_case()
|
||||
}
|
||||
|
||||
fn eq_ignore_case(&self, other: &str) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user