mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-01 13:31:02 -05:00
Merge pull request #615 from epage/crash
fix(cli): Have brief match long behavior
This commit is contained in:
commit
0f9beef18e
1 changed files with 5 additions and 9 deletions
|
@ -132,13 +132,9 @@ impl Report for PrintLong {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::Error> {
|
fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::Error> {
|
||||||
let line = String::from_utf8_lossy(msg.buffer.as_ref());
|
let start = String::from_utf8_lossy(&msg.buffer[0..msg.byte_offset]);
|
||||||
let line = line.replace('\t', " ");
|
let column_number =
|
||||||
let column = unicode_segmentation::UnicodeSegmentation::graphemes(
|
unicode_segmentation::UnicodeSegmentation::graphemes(start.as_ref(), true).count() + 1;
|
||||||
line.get(0..msg.byte_offset).unwrap(),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.count();
|
|
||||||
match &msg.corrections {
|
match &msg.corrections {
|
||||||
typos::Status::Valid => {}
|
typos::Status::Valid => {}
|
||||||
typos::Status::Invalid => {
|
typos::Status::Invalid => {
|
||||||
|
@ -148,7 +144,7 @@ fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::E
|
||||||
"{}{}{}: {}",
|
"{}{}{}: {}",
|
||||||
palette.info.paint(context_display(&msg.context)),
|
palette.info.paint(context_display(&msg.context)),
|
||||||
palette.info.paint(divider),
|
palette.info.paint(divider),
|
||||||
palette.info.paint(column),
|
palette.info.paint(column_number),
|
||||||
palette
|
palette
|
||||||
.strong
|
.strong
|
||||||
.paint(format_args!("`{}` is disallowed:", msg.typo)),
|
.paint(format_args!("`{}` is disallowed:", msg.typo)),
|
||||||
|
@ -161,7 +157,7 @@ fn print_brief_correction(msg: &Typo, palette: Palette) -> Result<(), std::io::E
|
||||||
"{}{}{}: {}",
|
"{}{}{}: {}",
|
||||||
palette.info.paint(context_display(&msg.context)),
|
palette.info.paint(context_display(&msg.context)),
|
||||||
palette.info.paint(divider),
|
palette.info.paint(divider),
|
||||||
palette.info.paint(column),
|
palette.info.paint(column_number),
|
||||||
palette.strong.paint(format_args!(
|
palette.strong.paint(format_args!(
|
||||||
"`{}` -> {}",
|
"`{}` -> {}",
|
||||||
msg.typo,
|
msg.typo,
|
||||||
|
|
Loading…
Reference in a new issue