Skip to content

Fix newline issues when adding multiple imports #38119

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
merged 2 commits into from
Apr 23, 2020

Conversation

andrewbranch
Copy link
Member

The logic in TextChanges for determining whether statements added to the top of a file need newlines before and after doesn’t really work when there are already other pending insertions at the top of the file. Instead of calling insertNodeAtTopOfFile for each import added, just call it once with an array of all the imports to be added.

Fixes #38082

Copy link
Contributor

@jessetrinity jessetrinity left a comment

Choose a reason for hiding this comment

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

The behavior in VS looks good to me.

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.

Looks correct, but I had some stylistic comments.

*/
export function combine<T>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I’ll give everyone until EOD to bikeshed this horribly vague name.

@andrewbranch andrewbranch merged commit 9569e8a into microsoft:master Apr 23, 2020
@andrewbranch andrewbranch deleted the bug/38082 branch April 23, 2020 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Add all missing imports" adds them all in one line
5 participants