Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix newline issues when adding multiple imports#38119

Merged
andrewbranch merged 2 commits into
microsoft:mastermicrosoft/TypeScript:masterfrom
andrewbranch:bug/38082andrewbranch/TypeScript:bug/38082Copy head branch name to clipboard
Apr 23, 2020
Merged

Fix newline issues when adding multiple imports#38119
andrewbranch merged 2 commits into
microsoft:mastermicrosoft/TypeScript:masterfrom
andrewbranch:bug/38082andrewbranch/TypeScript:bug/38082Copy head branch name to clipboard

Conversation

@andrewbranch

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

@jessetrinity jessetrinity left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/services/codefixes/importFixes.ts Outdated

@amcasey 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.

Looks correct, but I had some stylistic comments.

Comment thread src/services/textChanges.ts Outdated
Comment thread src/services/codefixes/importFixes.ts Outdated
Comment thread src/compiler/core.ts
*/
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
Copy Markdown
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
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.