mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
use case folding when sorting in canonify
This commit is contained in:
parent
ac4284b2de
commit
3b619c4ca5
1 changed files with 4 additions and 1 deletions
|
@ -5,6 +5,7 @@ use crate::collection::Collection;
|
||||||
use crate::err::Result;
|
use crate::err::Result;
|
||||||
use crate::types::Usn;
|
use crate::types::Usn;
|
||||||
use std::{borrow::Cow, collections::HashSet};
|
use std::{borrow::Cow, collections::HashSet};
|
||||||
|
use unicase::UniCase;
|
||||||
|
|
||||||
fn split_tags(tags: &str) -> impl Iterator<Item = &str> {
|
fn split_tags(tags: &str) -> impl Iterator<Item = &str> {
|
||||||
tags.split(|c| c == ' ' || c == '\u{3000}')
|
tags.split(|c| c == ' ' || c == '\u{3000}')
|
||||||
|
@ -23,7 +24,7 @@ impl Collection {
|
||||||
if matches!(tag, Cow::Borrowed(_)) {
|
if matches!(tag, Cow::Borrowed(_)) {
|
||||||
added = true;
|
added = true;
|
||||||
}
|
}
|
||||||
tagset.insert(tag);
|
tagset.insert(UniCase::new(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
if tagset.is_empty() {
|
if tagset.is_empty() {
|
||||||
|
@ -33,6 +34,8 @@ impl Collection {
|
||||||
let mut tags = tagset.into_iter().collect::<Vec<_>>();
|
let mut tags = tagset.into_iter().collect::<Vec<_>>();
|
||||||
tags.sort_unstable();
|
tags.sort_unstable();
|
||||||
|
|
||||||
|
let tags: Vec<_> = tags.into_iter().map(|s| s.into_inner()).collect();
|
||||||
|
|
||||||
Ok((format!(" {} ", tags.join(" ")), added))
|
Ok((format!(" {} ", tags.join(" ")), added))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue