davidbonnet / astring

🌳 Tiny and fast JavaScript code generator from an ESTree-compliant AST.
https://david.bonnet.cc/astring/demo/
MIT License
1.17k stars 57 forks source link

fix: block comment spacing #706

Open mohd-akram opened 5 months ago

mohd-akram commented 5 months ago

Fixes #705

davidbonnet commented 3 months ago

Thanks for submitting this @mohd-akram. IMHO, astring should not alter comment blocks at all (it was an initial design decision that became silly), so that it does what you would expect. Thus, only the leading spaces of comments would be updated to accommodate the current identation, but not the trailing ones.

WDYT?

mohd-akram commented 3 months ago

I agree, but I think trailing spaces followed by a newline can also be removed as they serve no purpose. In this PR, leading spaces are removed if they are preceded by an indent, and trailing spaces are removed if they are followed by a newline. The issue was that previously it trimmed trailing spaces between the comment text and */.