mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 00:51:11 -05:00
refactor: Restore str processing
This is in prep for using unicase.
This commit is contained in:
parent
5992ba110d
commit
719cc7d43b
1 changed files with 15 additions and 14 deletions
29
src/lib.rs
29
src/lib.rs
|
@ -17,20 +17,21 @@ pub fn process_file(path: &std::path::Path, dictionary: &Dictionary, report: rep
|
||||||
for (line_idx, line) in grep_searcher::LineIter::new(b'\n', &buffer).enumerate() {
|
for (line_idx, line) in grep_searcher::LineIter::new(b'\n', &buffer).enumerate() {
|
||||||
let line_num = line_idx + 1;
|
let line_num = line_idx + 1;
|
||||||
for token in tokens::Symbol::parse(line) {
|
for token in tokens::Symbol::parse(line) {
|
||||||
// Correct tokens as-is
|
if let Some(word) = std::str::from_utf8(token.token).ok() {
|
||||||
if let Some(correction) = dictionary.correct_bytes(token.token) {
|
// Correct tokens as-is
|
||||||
let word = String::from_utf8_lossy(token.token);
|
if let Some(correction) = dictionary.correct_str(word) {
|
||||||
let col_num = token.offset;
|
let col_num = token.offset;
|
||||||
let msg = report::Message {
|
let msg = report::Message {
|
||||||
path,
|
path,
|
||||||
line,
|
line,
|
||||||
line_num,
|
line_num,
|
||||||
col_num,
|
col_num,
|
||||||
word: word.as_ref(),
|
word,
|
||||||
correction,
|
correction,
|
||||||
non_exhaustive: (),
|
non_exhaustive: (),
|
||||||
};
|
};
|
||||||
report(msg);
|
report(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue