diff options
| author | Stéphane Campinas <stephane.campinas@gmail.com> | 2019-01-16 23:06:28 +0100 |
|---|---|---|
| committer | Stéphane Campinas <stephane.campinas@gmail.com> | 2019-01-16 23:06:28 +0100 |
| commit | 083a20fb1aee4daef685735652ae21e9b370350d (patch) | |
| tree | 76abade5132ecabba1eec46df98343fe75135e7f /src/utils.rs | |
| parent | baa62c609e421c4518070958df9ef721c20857e1 (diff) | |
version-gate the formatting of commented strings
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/utils.rs b/src/utils.rs index dd480f9788f..2f357d7e359 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -22,7 +22,7 @@ use syntax::source_map::{BytePos, Span, NO_EXPANSION}; use syntax_pos::Mark; use comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses}; -use config::Config; +use config::{Config, Version}; use rewrite::RewriteContext; use shape::{Indent, Shape}; @@ -527,8 +527,9 @@ pub fn trim_left_preserve_layout(orig: &str, indent: Indent, config: &Config) -> Some(get_prefix_space_width(config, &line)) }; - let new_veto_trim_value = - (kind.is_string() || kind.is_commented_string()) && !line.ends_with('\\'); + let new_veto_trim_value = (kind.is_string() + || (config.version() == Version::Two && kind.is_commented_string())) + && !line.ends_with('\\'); let line = if veto_trim || new_veto_trim_value { veto_trim = new_veto_trim_value; trimmed = false; @@ -541,10 +542,12 @@ pub fn trim_left_preserve_layout(orig: &str, indent: Indent, config: &Config) -> // Because there is a veto against trimming and indenting lines within a string, // such lines should not be taken into account when computing the minimum. match kind { - FullCodeCharKind::InString - | FullCodeCharKind::EndString - | FullCodeCharKind::InStringCommented - | FullCodeCharKind::EndStringCommented => None, + FullCodeCharKind::InStringCommented | FullCodeCharKind::EndStringCommented + if config.version() == Version::Two => + { + None + } + FullCodeCharKind::InString | FullCodeCharKind::EndString => None, _ => prefix_space_width, } }) |
