mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
test(dict): Report more cases to user
This commit is contained in:
parent
09f096a096
commit
a9d9fc03a2
1 changed files with 12 additions and 3 deletions
|
@ -91,11 +91,20 @@ fn generate<W: std::io::Write>(file: &mut W, dict: &[u8]) {
|
|||
current.extend(good);
|
||||
}
|
||||
|
||||
let corrections: std::collections::HashSet<_> =
|
||||
dict.values().flatten().map(ToOwned::to_owned).collect();
|
||||
let corrections: HashMap<_, _> = dict
|
||||
.iter()
|
||||
.flat_map(|(bad, good)| good.iter().map(|good| (good.to_owned(), bad.to_owned())))
|
||||
.collect();
|
||||
let rows: Vec<_> = dict
|
||||
.into_iter()
|
||||
.filter(|(typo, _)| !corrections.contains(typo.as_str()))
|
||||
.filter(|(typo, _)| {
|
||||
if let Some(correction) = corrections.get(typo.as_str()) {
|
||||
eprintln!("{typo} <-> {correction} cycle detected");
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut wtr = csv::WriterBuilder::new().flexible(true).from_writer(file);
|
||||
|
|
Loading…
Reference in a new issue