Merge pull request #2413 from topecongiro/issue-2401

Use correct offset when unindenting code block
This commit is contained in:
Nick Cameron 2018-02-05 08:44:21 +13:00 committed by GitHub
commit c45c20378f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -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
}

View file

@ -0,0 +1,7 @@
// rustfmt-hard_tabs = true
// rustfmt-normalize_comments = true
/// ```
/// println!("Hello, World!");
/// ```
fn main() {}