Skip to content

Commit

Permalink
Correctly indent skipped-over code
Browse files Browse the repository at this point in the history
  • Loading branch information
ayazhafiz committed Aug 26, 2020
1 parent f7ba2db commit 945145d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/formatting/missed_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ impl<'a> FmtVisitor<'a> {

let remaining = snippet[status.line_start..subslice.len() + offset].trim();
if !remaining.is_empty() {
self.push_str(&self.block_indent.to_string(self.config));
self.push_str(remaining);
status.line_start = subslice.len() + offset;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/source/issue-4398.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}

impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}

/// Documentation for `Struct`
#[rustfmt::skip] // comment
impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}
19 changes: 19 additions & 0 deletions tests/target/issue-4398.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}

impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}

/// Documentation for `Struct`
#[rustfmt::skip] // comment
impl Struct {
/// Documentation for `foo`
#[rustfmt::skip] // comment on why use a skip here
pub fn foo(&self) {}
}

0 comments on commit 945145d

Please sign in to comment.