Skip to content

Commit 9e79b8d

Browse files
committed
refactor(cli): Give control over the whole group
1 parent a5fa603 commit 9e79b8d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/typos-cli/src/bin/typos-cli/report.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ fn typo_to_group<'t>(msg: &'t Typo<'t>) -> Group<'t> {
166166
let snippet = Snippet::source(line)
167167
.path(path)
168168
.line_start(context.line_num);
169-
let snippet = append_corrections(msg, 0, snippet);
170-
group.element(snippet)
169+
append_corrections(msg, 0, snippet, group)
171170
}
172171
Some(Context::Path(context)) => {
173172
let path = context
@@ -178,8 +177,7 @@ fn typo_to_group<'t>(msg: &'t Typo<'t>) -> Group<'t> {
178177
let path = path.as_os_str().to_string_lossy();
179178
let line = context.path.as_os_str().to_string_lossy();
180179
let snippet = Snippet::source(line);
181-
let snippet = append_corrections(msg, path.len(), snippet);
182-
group.element(snippet)
180+
append_corrections(msg, path.len(), snippet, group)
183181
}
184182
Some(_) | None => group,
185183
};
@@ -190,11 +188,13 @@ fn append_corrections<'t>(
190188
msg: &'t Typo<'t>,
191189
offset: usize,
192190
snippet: Snippet<'t, Annotation<'t>>,
193-
) -> Snippet<'t, Annotation<'t>> {
191+
group: Group<'t>,
192+
) -> Group<'t> {
194193
let span_start = msg.byte_offset + offset;
195194
let span_end = span_start + msg.typo.len();
196195
let span = span_start..span_end;
197-
snippet.annotation(AnnotationKind::Primary.span(span))
196+
let snippet = snippet.annotation(AnnotationKind::Primary.span(span));
197+
group.element(snippet)
198198
}
199199

200200
fn error_to_group<'e>(error: &'e Error<'e>) -> Group<'e> {

0 commit comments

Comments
 (0)