Repository: sveltejs/prettier-plugin-svelte (ts)

Issue:
Comments get removed from formated Svelte Component
Hi when I format a svelte component, any comment that is at the end of an element gets removed.

Gets removed:
```
<div>
    <div/>
    <!-- testing 123 -->
</div>
```

Doesn't get removed:
```
<div>
    <!-- testing 123 -->
    <div/>
</div>
```

Any solutions?

Pull request description:
(fix) embed check
When checking if an embed starts after a node, return early if that node is not at the top level of html, because embeds cannot start after it.
Fixes #207

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef4a502..7e8b07f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # prettier-plugin-svelte changelog
 
+## 2.1.6 (Unreleased)
+
+* Fix wrong removal of comment ([#207](https://github.com/sveltejs/prettier-plugin-svelte/issues/207))
+
 ## 2.1.5
 
 * Fix retrieval of comment belonging to `<script>`/`<style>` block ([#205](https://github.com/sveltejs/prettier-plugin-svelte/issues/205))
diff --git a/src/print/node-helpers.ts b/src/print/node-helpers.ts
index f040456..8c8aa7e 100644
--- a/src/print/node-helpers.ts
+++ b/src/print/node-helpers.ts
@@ -128,6 +128,12 @@ export function getLeadingComment(path: FastPath): CommentNode | undefined {
 export function doesEmbedStartAfterNode(node: Node, path: FastPath, siblings = getSiblings(path)) {
     const position = node.end;
     const root = path.stack[0];
+    // If node is not at the top level of html, an embed cannot start after it,
+    // because embeds are only at the top level
+    if (!root.html || !root.html.children || !root.html.children.includes(node)) {
+        return false;
+    }
+
     const embeds = [root.css, root.html, root.instance, root.js, root.module] as Node[];
 
     const nextNode = siblings[siblings.indexOf(node) + 1];


Test patch:
diff --git a/test/printer/samples/comment-at-end.html b/test/printer/samples/comment-at-end.html
new file mode 100644
index 0000000..cceefa9
--- /dev/null
+++ b/test/printer/samples/comment-at-end.html
@@ -0,0 +1,6 @@
+<div>
+    <div />
+    <!-- testing 123 -->
+</div>
+
+<style></style>