Hi @Johan,
Welcome to Microsoft Q&A!
Do you mean that it only occurs in .razor file?
Please update your VS2022 to the latest version and check it again.
If you have some extensions installed, please temporarily disable or uninstall them under Extensions > Manage Extensions > Installed.
Besides, I found a similar issue has been reported in Developer Community. You can also vote on that ticket and add your comments to track the process.
Sincerely,
Anna
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.