Allow multiple code actions if there is more than one SuggestedCorrection of a diagnostic record returned by PSSA #1713
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.
Currently, PSSA's
SuggestCorrections
property of theDiagnosticRecord
object already is an array but no built-in rules return more than one suggested correction, which lead toPowerShellEditorServices
not correctly translating this array before returning it as an code action but it only ever displayed one. This fixes it makes it generic again so it returns a code action for each suggest correction. It's basically just performing a foreach loop and callingToTextEdit
just once, a diff that ignored whitespace due to increased indentation will make this much clearerThis is a pre-requisite for an implementation of this, where a built-inrule will return multiple suggest corrections: PowerShell/PSScriptAnalyzer#1767
I've manually tested this with a modified version of PSSA where I return 2 suggested corrections and when I build the PS extension with this change, the UI shows me the two different suggested code actions and also applies them correctly (as in they are different as they should be by design)