diff --git a/src/printer.mjs b/src/printer.mjs index a9f06c170..5d6807ab6 100644 --- a/src/printer.mjs +++ b/src/printer.mjs @@ -1039,9 +1039,9 @@ function printLines(path, options, print, childrenAttribute = "children") { const beforeInline = childNode.leadingComments && childNode.leadingComments.length ? [ - isFirstNode && node.kind !== "namespace" && !isBlockNestedNode - ? " +

x

+ + +=====================================output===================================== + +

x

+ + +================================================================================ +`; + +exports[`if.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + +

Heading

+ + +=====================================output===================================== + +

Heading

+ + +================================================================================ +`; + +exports[`while.php 1`] = ` +====================================options===================================== +parsers: ["php"] +printWidth: 80 + | printWidth +=====================================input====================================== + +

post

+ + +=====================================output===================================== + +

post

+ + +================================================================================ +`; diff --git a/tests/inline-comment-after-if/braces.php b/tests/inline-comment-after-if/braces.php new file mode 100644 index 000000000..462a74fa7 --- /dev/null +++ b/tests/inline-comment-after-if/braces.php @@ -0,0 +1,5 @@ + +

x

+ diff --git a/tests/inline-comment-after-if/if.php b/tests/inline-comment-after-if/if.php new file mode 100644 index 000000000..4d1d87990 --- /dev/null +++ b/tests/inline-comment-after-if/if.php @@ -0,0 +1,4 @@ + +

Heading

+ diff --git a/tests/inline-comment-after-if/jsfmt.spec.mjs b/tests/inline-comment-after-if/jsfmt.spec.mjs new file mode 100644 index 000000000..8829c872f --- /dev/null +++ b/tests/inline-comment-after-if/jsfmt.spec.mjs @@ -0,0 +1 @@ +run_spec(import.meta, ["php"]); diff --git a/tests/inline-comment-after-if/while.php b/tests/inline-comment-after-if/while.php new file mode 100644 index 000000000..53812af44 --- /dev/null +++ b/tests/inline-comment-after-if/while.php @@ -0,0 +1,4 @@ + +

post

+