ctran/annotate_models

Comments get lost when generating annotations

Opened this issue · 7 comments

cmer commented

When there are already comments above a class definition, AnnotateModels deletes them when regenerating annotations.

Here's a short video showing the issue: https://cln.sh/Iw7NsPk7yEfmkyPWtIim

Version

  • annotate version: 3.2
  • rails version: 5.2.6.2
  • ruby version: 2.7.5

running into this as well

It works to add a blank line above the comment before annotating, but you need to find them first (I spotted it accidentally when reviewing a PR).

cmer commented

Sorry, it's actually worse than I thought. It looked like it worked only because the comment wasn't getting regenerated. If I use --force (or do a schema change which forces a regeneration), then the first time eats the empty line and leaves the comment intact (so really hard to note in code review), and the next time eats the comment 🤣.

Is there a workaround for this?

drwl commented

Hey folks, I believe I was able to solve this bug in my gem drwl/annotaterb#72

I wasn't aware of the fork. I'll definitely check it out. Thanks!