forked from decaffeinate/decaffeinate
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't remove comments when removing trailing empty returns
Before this commit, the comment after a removed return statement would be destroyed: http://decaffeinate-project.org/repl/#?evaluate=true&code=-%3E%0A%20%20a%20%20%23%20foo%0A%20%20return Now, the code is a little more careful by deleting up to the start of the line or the previous semicolon. Also, the code now exits early and doesn't patch the `return` node or insert a semicolon at the end, since that was causing a semicolon at the end of the comment. This also fixes a crash on this type of input that I ran into when using magic-string with Rich-Harris/magic-string#89 applied.
- Loading branch information
1 parent
577134b
commit 6cf041e
Showing
2 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters