Skip to content

Commit ba9b1bf

Browse files
committed
add line number to skipped_range for stmt
1 parent 6fec3a6 commit ba9b1bf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/expr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ pub(crate) fn rewrite_block_with_visitor(
517517
let inner_attrs = attrs.map(inner_attributes);
518518
let label_str = rewrite_label(label);
519519
visitor.visit_block(block, inner_attrs.as_ref().map(|a| &**a), has_braces);
520+
let visitor_context = visitor.get_context();
521+
context
522+
.skipped_range
523+
.borrow_mut()
524+
.append(&mut visitor_context.skipped_range.borrow_mut().clone());
520525
Some(format!("{}{}{}", prefix, label_str, visitor.buffer))
521526
}
522527

src/visitor.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,17 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
120120
ast::StmtKind::Local(..) | ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
121121
let attrs = get_attrs_from_stmt(stmt.as_ast_node());
122122
if contains_skip(attrs) {
123+
let span = stmt.span();
123124
self.push_skipped_with_span(
124125
attrs,
125-
stmt.span(),
126+
span,
126127
get_span_without_attrs(stmt.as_ast_node()),
127128
);
129+
let context = self.get_context();
130+
context.skipped_range.borrow_mut().push((
131+
context.source_map.lookup_line(span.lo()).unwrap().line,
132+
context.source_map.lookup_line(span.hi()).unwrap().line,
133+
));
128134
} else {
129135
let shape = self.shape();
130136
let rewrite = self.with_context(|ctx| stmt.rewrite(&ctx, shape));

0 commit comments

Comments
 (0)