prettier-plugin-go-template
prettier-plugin-go-template copied to clipboard
Lines containing variable definitions cause double-empty lines
First off, thanks for this excellent plugin!
One thing I've noticed is that when a line containing a variable definition has no trailing space, and that same line is followed by a single empty line, the plugin appends a second empty line. Here's a video using the playground that shows this behavior:
https://user-images.githubusercontent.com/274700/183225768-c066bb8c-5e9e-4b16-8bfe-331d228bb0c0.mov
When there is a trailing space, however, the plugin keeps just one empty line.
I don't see a test that covers this case, but I do see one that covers removing multiple empty lines, so I'm assuming, since two consecutive lines isn't a Go template convention, that this is a legitimate bug. Happy to take a shot at fixing it myself, but figured I'd post here first in case it's either an easy fix or something you could provide me with a little guidance on before I go spelunking.
Thanks again and appreciate your help!
Just noticed this comment also, which seems like it may be related:
https://github.com/NiklasPor/prettier-plugin-go-template/issues/56#issuecomment-873311542
Hey, thanks for reporting!
Sadly bugs like these aren't quite easy to fix, as this whole plugin is based around heuristics (regex 😂) which extract all go-interpolation and invokes the regular HTML formatter — I didn't want to invest the time to write a new one here for obvious reasons.
If you're able to fix this I'll surely accept a PR 🚀