]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: move the space at the end of where clauses
authorQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 6 Apr 2017 23:36:14 +0000 (18:36 -0500)
committerQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 6 Apr 2017 23:36:14 +0000 (18:36 -0500)
...so that we don't indent the next line by one extra space

src/librustdoc/html/format.rs

index 13a31c557021ddd55690ffd80ab116c668766c3f..d9bbc957c8a2d5733be9cfe1a4ca6ace6208bbd2 100644 (file)
@@ -237,15 +237,23 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 clause.push(',');
             }
         }
+
+        if end_newline {
+            //add a space so stripping <br> tags and breaking spaces still renders properly
+            if f.alternate() {
+                clause.push(' ');
+            } else {
+                clause.push_str("&nbsp;");
+            }
+        }
+
         if !f.alternate() {
             clause.push_str("</span>");
             let padding = repeat("&nbsp;").take(indent + 4).collect::<String>();
             clause = clause.replace("<br>", &format!("<br>{}", padding));
             clause.insert_str(0, &repeat("&nbsp;").take(indent.saturating_sub(1))
                                                   .collect::<String>());
-            if end_newline {
-                clause.push(' ');
-            } else {
+            if !end_newline {
                 clause.insert_str(0, "<br>");
             }
         }