Keep single line comments after nlb, after nlb
authorAnthony Van de Gejuchte <anthonyvdgent@yahoo.com>
Fri, 9 Jan 2015 15:46:40 +0000 (16:46 +0100)
committerRichard van Velzen <rvanvelzen1@gmail.com>
Mon, 26 Jan 2015 11:11:52 +0000 (12:11 +0100)
Fixes #583

lib/output.js

index 72bcdd5..bfe6242 100644 (file)
@@ -413,6 +413,15 @@ function OutputStream(options) {
                         return c(self, comment);
                     });
                 }
+
+                // Keep single line comments after nlb, after nlb
+                if (!output.option("beautify") && comments.length > 0 &&
+                    /comment[134]/.test(comments[0].type) &&
+                    output.col() !== 0 && comments[0].nlb)
+                {
+                    output.print("\n");
+                }
+
                 comments.forEach(function(c){
                     if (/comment[134]/.test(c.type)) {
                         output.print("//" + c.value + "\n");