Skip to content

Commit

Permalink
fix: use utf16CodeUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Jul 23, 2024
1 parent 7a834d0 commit f9be168
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/typos-cli/src/bin/typos-cli/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,8 @@ impl PrintSarif {
};

let start = String::from_utf8_lossy(&msg.buffer[0..msg.byte_offset]);
let column_start =
unicode_segmentation::UnicodeSegmentation::graphemes(start.as_ref(), true).count() + 1;
let column_end =
unicode_segmentation::UnicodeSegmentation::graphemes(msg.typo, true).count() + column_start;
let column_start = start.encode_utf16().count() + 1;
let column_end = msg.typo.encode_utf16().count() + column_start;
let line_num = msg.context.as_ref().map(|context| match context {
Context::File(context) => context.line_num,
_ => 1,
Expand Down Expand Up @@ -402,7 +400,7 @@ impl PrintSarif {
let mut run_builder = sarif::RunBuilder::default();
run_builder
.tool(tool)
.column_kind(sarif::ResultColumnKind::UnicodeCodePoints.to_string())
.column_kind(sarif::ResultColumnKind::Utf16CodeUnits.to_string())
.results(self.results.lock().unwrap().clone());

if !self.error.lock().unwrap().is_empty() {
Expand Down

0 comments on commit f9be168

Please sign in to comment.