microsoft / Power-Fx

Power Fx low-code programming language
MIT License
3.15k stars 309 forks source link

Extend Script Minification to also allow removing comments #2499

Closed akshar2401 closed 3 days ago

akshar2401 commented 4 days ago

This pr mainly focuses on extending existing script minification functionality (or remove formatting as it is called) with an ability to optionally removing comments. Removing comment tokens is not harmful as those are removed from the parse tree anyways. Along the way, i found few bugs in existing implementation of remove formatting that adds extra spaces instead of removing those like below image

I also found a bug in TexlLexer that computes overlapping spans of tokens from LexComment() when it tries to consume preceding whitespaces of the first comment in the formula. This was supposed to be fix last year when this was addressed during semantic tokens work but seems like an edge case was missed.

I am keeping all the bug fixes out of scope for now since these are very low priority and remove formatting is not that widely used.