Open ghostbuster91 opened 9 months ago
Hey, thanks for the detailed issue. This should be easy to fix.
With that said, the smithy-cli officially has support for formatting and should be the good to in the future. We're aware that most people that use our formatter do it because it comes bundled in the smithy-language-server (so indirectly files are formatted within the IDE) and that's why we try to keep the lights on here.
Let me take a look at that real quick
Before spending time on this, I decided to look at the LSP and see if we could use the official formatter (which handles this case correctly) and turns out it was a relatively easy swap, so I opened a PR there. I'll wait for feedback there before proceeding with a fix here. The reason is that even if I fix it here, we still have to bump the version in the LSP after that so your IDE gets formatting correctly.
Instead, the PR referenced above removes the middleman and just uses the official formatter, so it removes the middleman and fix the issue.
Problem description
If the first shape definition in a smithy file has a documentation comment attached, that comment gets detached from it if there are any imports above.
Actual behavior
Formatting the following example smithy definition:
gives:
Expected behavior
I would expect the documentation comment to be still attached to the structure that it was defined for.
tested on 8111fddbfca65fc44eeefd9acdc99db9a143d3d4