sway
sway copied to clipboard
Fix parse error when whitespace precedes comments
This should be the last piece of the puzzle for ensuring that comments before module kind will always work. As apposed to the newline map where we can just trim the start of the source code, we have to approach it a little differently since we are using functions that leave the source code in tact as an Arc<str>
. We check if the src code starts with a newline, then we count the number of newlines, then we pass that offset to where we previously checked that the program started with a comment and add the offset to that logic. Finally we trim the comment string start to be sure the program start is the intended comment.
@mohammadfawaz @Braqzen with this, you'll finally be able to format programs that start with multiple comments, whether they have whitespace before them or not