mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-29 04:21:06 -05:00
fix: Improve accuracy of col_num field name
This commit is contained in:
parent
7c41be2c1a
commit
8a619e7e39
2 changed files with 13 additions and 13 deletions
|
@ -238,10 +238,10 @@ impl Checks {
|
||||||
if let Some(part) = path.file_name().and_then(|s| s.to_str()) {
|
if let Some(part) = path.file_name().and_then(|s| s.to_str()) {
|
||||||
for ident in parser.parse(part) {
|
for ident in parser.parse(part) {
|
||||||
if let Some(correction) = dictionary.correct_ident(ident) {
|
if let Some(correction) = dictionary.correct_ident(ident) {
|
||||||
let col_num = ident.offset();
|
let byte_offset = ident.offset();
|
||||||
let msg = report::PathCorrection {
|
let msg = report::PathCorrection {
|
||||||
path,
|
path,
|
||||||
col_num,
|
byte_offset,
|
||||||
typo: ident.token(),
|
typo: ident.token(),
|
||||||
correction,
|
correction,
|
||||||
non_exhaustive: (),
|
non_exhaustive: (),
|
||||||
|
@ -251,10 +251,10 @@ impl Checks {
|
||||||
} else {
|
} else {
|
||||||
for word in ident.split() {
|
for word in ident.split() {
|
||||||
if let Some(correction) = dictionary.correct_word(word) {
|
if let Some(correction) = dictionary.correct_word(word) {
|
||||||
let col_num = word.offset();
|
let byte_offset = word.offset();
|
||||||
let msg = report::PathCorrection {
|
let msg = report::PathCorrection {
|
||||||
path,
|
path,
|
||||||
col_num,
|
byte_offset,
|
||||||
typo: word.token(),
|
typo: word.token(),
|
||||||
correction,
|
correction,
|
||||||
non_exhaustive: (),
|
non_exhaustive: (),
|
||||||
|
@ -299,12 +299,12 @@ impl Checks {
|
||||||
let line_num = line_idx + 1;
|
let line_num = line_idx + 1;
|
||||||
for ident in parser.parse_bytes(line) {
|
for ident in parser.parse_bytes(line) {
|
||||||
if let Some(correction) = dictionary.correct_ident(ident) {
|
if let Some(correction) = dictionary.correct_ident(ident) {
|
||||||
let col_num = ident.offset();
|
let byte_offset = ident.offset();
|
||||||
let msg = report::Correction {
|
let msg = report::Correction {
|
||||||
path,
|
path,
|
||||||
line,
|
line,
|
||||||
line_num,
|
line_num,
|
||||||
col_num,
|
byte_offset,
|
||||||
typo: ident.token(),
|
typo: ident.token(),
|
||||||
correction,
|
correction,
|
||||||
non_exhaustive: (),
|
non_exhaustive: (),
|
||||||
|
@ -314,12 +314,12 @@ impl Checks {
|
||||||
} else {
|
} else {
|
||||||
for word in ident.split() {
|
for word in ident.split() {
|
||||||
if let Some(correction) = dictionary.correct_word(word) {
|
if let Some(correction) = dictionary.correct_word(word) {
|
||||||
let col_num = word.offset();
|
let byte_offset = word.offset();
|
||||||
let msg = report::Correction {
|
let msg = report::Correction {
|
||||||
path,
|
path,
|
||||||
line,
|
line,
|
||||||
line_num,
|
line_num,
|
||||||
col_num,
|
byte_offset,
|
||||||
typo: word.token(),
|
typo: word.token(),
|
||||||
correction,
|
correction,
|
||||||
non_exhaustive: (),
|
non_exhaustive: (),
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub struct Correction<'m> {
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub line: &'m [u8],
|
pub line: &'m [u8],
|
||||||
pub line_num: usize,
|
pub line_num: usize,
|
||||||
pub col_num: usize,
|
pub byte_offset: usize,
|
||||||
pub typo: &'m str,
|
pub typo: &'m str,
|
||||||
pub correction: Cow<'m, str>,
|
pub correction: Cow<'m, str>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
@ -40,7 +40,7 @@ pub struct Correction<'m> {
|
||||||
#[derive(Clone, Debug, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Serialize)]
|
||||||
pub struct PathCorrection<'m> {
|
pub struct PathCorrection<'m> {
|
||||||
pub path: &'m std::path::Path,
|
pub path: &'m std::path::Path,
|
||||||
pub col_num: usize,
|
pub byte_offset: usize,
|
||||||
pub typo: &'m str,
|
pub typo: &'m str,
|
||||||
pub correction: Cow<'m, str>,
|
pub correction: Cow<'m, str>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
|
@ -129,7 +129,7 @@ impl Report for PrintBrief {
|
||||||
"{}:{}:{}: {} -> {}",
|
"{}:{}:{}: {} -> {}",
|
||||||
msg.path.display(),
|
msg.path.display(),
|
||||||
msg.line_num,
|
msg.line_num,
|
||||||
msg.col_num,
|
msg.byte_offset,
|
||||||
msg.typo,
|
msg.typo,
|
||||||
msg.correction
|
msg.correction
|
||||||
);
|
);
|
||||||
|
@ -197,7 +197,7 @@ fn print_long_correction(msg: Correction) {
|
||||||
let line_num = msg.line_num.to_string();
|
let line_num = msg.line_num.to_string();
|
||||||
let line_indent: String = itertools::repeat_n(" ", line_num.len()).collect();
|
let line_indent: String = itertools::repeat_n(" ", line_num.len()).collect();
|
||||||
|
|
||||||
let hl_indent: String = itertools::repeat_n(" ", msg.col_num).collect();
|
let hl_indent: String = itertools::repeat_n(" ", msg.byte_offset).collect();
|
||||||
let hl: String = itertools::repeat_n("^", msg.typo.len()).collect();
|
let hl: String = itertools::repeat_n("^", msg.typo.len()).collect();
|
||||||
|
|
||||||
let line = String::from_utf8_lossy(msg.line);
|
let line = String::from_utf8_lossy(msg.line);
|
||||||
|
@ -217,7 +217,7 @@ fn print_long_correction(msg: Correction) {
|
||||||
" --> {}:{}:{}",
|
" --> {}:{}:{}",
|
||||||
msg.path.display(),
|
msg.path.display(),
|
||||||
msg.line_num,
|
msg.line_num,
|
||||||
msg.col_num
|
msg.byte_offset
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
writeln!(handle, "{} |", line_indent).unwrap();
|
writeln!(handle, "{} |", line_indent).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue