I’ve noticed that the vscode auto-formatter deletes comments in some circumstances. In the following code block, only the comment at the beginning remains after applying the auto-formatter. Is that intentional or is that a bug?
/*
comment at the beginning
*/
XYZ(
abc,
xxx,
// comment inside function
)
/*
block comment not at the beginning
*/
It is a limitation of the formatter. In general, the formatter can preserve comments before a statement and comments at the end of a statement on the same line (e.g. after the parentheses in your example). This can cover most comments if you organize them a certain way.
It’s a heuristic until we can find a more comprehensive solution. I’ll need to study how other languages typically do this, but I think it involves saving a lot more parser information than we are currently.