Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add option to OrganizeImports for removal only #50931
Add option to OrganizeImports for removal only #50931
Changes from 4 commits
b99e35f
742ddfa
ae0dfb6
0d06478
6b35ddc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While the PR focuses on the
RemoveUnused
... I'm more excited aboutSortAndCombine
:P I see thatskipDestructiveCodeActions
was a thing (didn't know about it), gonna give it a try in my projects for nowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, to be clear,
SortAndCombine
ought to be identical to settingskipDestructiveCodeActions
which is already set in a VS Code code action calledsortImports
. (It’s not very discoverable because I learned recently that these code actions lack autocomplete support in the VS Code settings.json files.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ye, I got the fact that this one isn't a new option - but I had no idea that it was already a thing. So I'm glad that I've discovered that old option through this PR :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out how to actually use this old option in VS Code. I've found this in the source code:
https://github.com/microsoft/vscode/blob/3a8b1fe03ebbcf57fb9c50b161db91229e2fe04a/extensions/typescript-language-features/src/languageFeatures/organizeImports.ts#L50
I've tried a lot of combinations with
_typescript.*
,typescript.*
,source.*
and*.organizeImports.sortOnly: true
but none of those work for me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Organize Imports is a VS Code standard command, and so automatically appears in the command palette when registered. These variations are registered so can be triggered by ID in configurations like
codeActionsOnSave
, but I think we would need to add them to thecontributes
of the extension package.json to show up in the command palette. @mjbvz is that correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
skipDestructiveCodeActions
was vaguely named due to aspirations of being used in more than one place, but it didn’t end up that way. FWIW, VS never picked this argument up, so it’s likely only VS Code that uses it.