From 7c41be2c1a7e77e825e2f1c755c62528dcefeb83 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 31 Mar 2020 19:52:53 -0500 Subject: [PATCH] feat: Track path's column --- typos/src/checks.rs | 4 ++++ typos/src/report.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/typos/src/checks.rs b/typos/src/checks.rs index 8bd809c..3ed303e 100644 --- a/typos/src/checks.rs +++ b/typos/src/checks.rs @@ -238,8 +238,10 @@ impl Checks { if let Some(part) = path.file_name().and_then(|s| s.to_str()) { for ident in parser.parse(part) { if let Some(correction) = dictionary.correct_ident(ident) { + let col_num = ident.offset(); let msg = report::PathCorrection { path, + col_num, typo: ident.token(), correction, non_exhaustive: (), @@ -249,8 +251,10 @@ impl Checks { } else { for word in ident.split() { if let Some(correction) = dictionary.correct_word(word) { + let col_num = word.offset(); let msg = report::PathCorrection { path, + col_num, typo: word.token(), correction, non_exhaustive: (), diff --git a/typos/src/report.rs b/typos/src/report.rs index a472397..c4d7034 100644 --- a/typos/src/report.rs +++ b/typos/src/report.rs @@ -40,6 +40,7 @@ pub struct Correction<'m> { #[derive(Clone, Debug, serde::Serialize)] pub struct PathCorrection<'m> { pub path: &'m std::path::Path, + pub col_num: usize, pub typo: &'m str, pub correction: Cow<'m, str>, #[serde(skip)]