]> git.lizzy.rs Git - rust.git/blobdiff - src/string.rs
Remove BlockIndentStyle::Inherit
[rust.git] / src / string.rs
index 014830a9155a4ebf50bdb83979851803e53b84f8..8f51b09b6cc067240e85857121ad9cd950e5bad5 100644 (file)
@@ -32,24 +32,25 @@ pub struct StringFormat<'a> {
 // FIXME: simplify this!
 pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String> {
     // Strip line breaks.
-    let re = Regex::new(r"([^\\](\\\\)*)\\[\n\r][:space:]*").unwrap();
+    let re = Regex::new(r"([^\\](\\\\)*)\\[\n\r][[:space:]]*").unwrap();
     let stripped_str = re.replace_all(orig, "$1");
 
     let graphemes = UnicodeSegmentation::graphemes(&*stripped_str, false).collect::<Vec<&str>>();
-    let indent = fmt.shape.indent.to_string(fmt.config);
+    let shape = fmt.shape.visual_indent(0);
+    let indent = shape.indent.to_string(fmt.config);
     let punctuation = ":,;.";
 
     // `cur_start` is the position in `orig` of the start of the current line.
     let mut cur_start = 0;
     let mut result = String::with_capacity(stripped_str.len()
-        .checked_next_power_of_two()
-        .unwrap_or(usize::max_value()));
+                                               .checked_next_power_of_two()
+                                               .unwrap_or(usize::max_value()));
     result.push_str(fmt.opener);
 
     let ender_length = fmt.line_end.len();
     // If we cannot put at least a single character per line, the rewrite won't
     // succeed.
-    let max_chars = try_opt!(fmt.shape.width.checked_sub(fmt.opener.len() + ender_length + 1)) + 1;
+    let max_chars = try_opt!(shape.width.checked_sub(fmt.opener.len() + ender_length + 1)) + 1;
 
     // Snip a line at a time from `orig` until it is used up. Push the snippet
     // onto result.