Merge pull request #2413 from topecongiro/issue-2401
Use correct offset when unindenting code block
This commit is contained in:
commit
c45c20378f
2 changed files with 13 additions and 1 deletions
|
|
@ -571,7 +571,12 @@ pub fn format_code_block(code_snippet: &str, config: &Config) -> Option<String>
|
|||
let indent_str =
|
||||
Indent::from_width(config, config.tab_spaces()).to_string(config);
|
||||
if line.starts_with(indent_str.as_ref()) {
|
||||
&line[config.tab_spaces()..]
|
||||
let offset = if config.hard_tabs() {
|
||||
1
|
||||
} else {
|
||||
config.tab_spaces()
|
||||
};
|
||||
&line[offset..]
|
||||
} else {
|
||||
line
|
||||
}
|
||||
|
|
|
|||
7
tests/target/issue-2401.rs
Normal file
7
tests/target/issue-2401.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// rustfmt-hard_tabs = true
|
||||
// rustfmt-normalize_comments = true
|
||||
|
||||
/// ```
|
||||
/// println!("Hello, World!");
|
||||
/// ```
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue