Skip to content

Commit b6adfa3

Browse files
committed
Skipping formatting of some configuration snippets
1 parent 7c3a422 commit b6adfa3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Configurations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ lines are found, they are trimmed down to match this integer.
19281928
Original Code:
19291929

19301930
```rust
1931+
// rustfmt: skip
19311932
fn foo() {
19321933
println!("a");
19331934
}
@@ -1985,6 +1986,7 @@ them, additional blank lines are inserted.
19851986
Original Code (rustfmt will not change it with the default value of `0`):
19861987

19871988
```rust
1989+
// rustfmt: skip
19881990
fn foo() {
19891991
println!("a");
19901992
}

tests/system.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,16 @@ impl ConfigCodeBlock {
751751
loop {
752752
match ConfigurationSection::get_section(file) {
753753
Some(ConfigurationSection::CodeBlock((block, start_line))) => {
754+
if block
755+
.split("\n")
756+
.take_while(|l| l.starts_with("//"))
757+
.map(|l| l == "// rustfmt: skip")
758+
.fold(false, |acc, b| acc || b)
759+
{
760+
// Pass over code blocks containing the skip directive.
761+
continue;
762+
}
763+
754764
code_block.set_code_block(block, start_line);
755765
break;
756766
}

0 commit comments

Comments
 (0)