Skip to content

In insertNodeAfter, handle file with no trailing newline - #23814

Merged
1 commit merged into
masterfrom
insertNodeAfter_fileWithNoTrailingNewline
May 3, 2018
Merged

1 commit merged into
masterfrom
insertNodeAfter_fileWithNoTrailingNewline

Conversation

@ghost

Copy link
Copy Markdown

Fixes #23728

@ghost
ghost requested a review from Andrew Casey (amcasey) May 1, 2018 22:39
@ghost
ghost force-pushed the insertNodeAfter_fileWithNoTrailingNewline branch from 2cb684c to f5571e8 Compare May 2, 2018 16:38

@amcasey Andrew Casey (amcasey) left a comment

Copy link
Copy Markdown
Member

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.

description: "Convert function to an ES2015 class",
newFileContent:
`/** Doc */
`

Copy link
Copy Markdown
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
Copy Markdown
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 (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