Skip to content

In insertNodeAfter, handle file with no trailing newline #23814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
May 3, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 1, 2018

Fixes #23728

@ghost ghost requested a review from amcasey May 1, 2018 22:39
@ghost ghost force-pushed the insertNodeAfter_fileWithNoTrailingNewline branch from 2cb684c to f5571e8 Compare May 2, 2018 16:38
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there might be a corner case at BOF. Otherwise, LGTM.

@@ -8,7 +8,8 @@
verify.codeFix({
description: "Convert function to an ES2015 class",
newFileContent:
`/** Doc */
`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem great. What is the comment being inserted after that is resulting in the blank line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way convertFunctionToEs6Class works, we are deleting the function and adding a class node after it. In textChanges we don't know that the function is going to be deleted, so we add a newline to separate the old function and the new class. Added an issue at #23871

@ghost ghost merged commit bad3a44 into master May 3, 2018
@ghost ghost deleted the insertNodeAfter_fileWithNoTrailingNewline branch May 3, 2018 19:58
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants