-
Notifications
You must be signed in to change notification settings - Fork 233
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
Return a code action for each diagnostic record #1718
Conversation
Currently, PSSA's `SuggestCorrections` property of the `DiagnosticRecord` object already is an array, but no built-in rules return more than one suggested correction, which led to `PowerShellEditorServices` not correctly translating this array before returning it as an code action as it only ever displayed one. This fixes it by making it generic again so it returns a code action for each suggest correction. It's basically just performing a `foreach` loop and calling `ToTextEdit` just once. This is a pre-requisite for an implementation of this, where a built-in rule will return multiple suggest corrections: PowerShell/PSScriptAnalyzer#1767 I've manually tested this with a modified version of PSScriptAnalyzer where I return two suggested corrections. The extension's UI now shows me the two different suggested code actions and also applies them correctly.
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.
LGTM
Sorry, forgot about this one. Since this change is slightly different, will re-test just to confirm |
The actual changes should be no different, I cherry-picked the commit: a4c4fdf |
Ok, just seeing the other changes made me think there is a chance it could affect it. I tested with the latest preview extension since it's already released and can confirm it still works the way I tested it with my own build :-) |
Yay! Thanks for testing!! |
With the recent fix in PR #1718, PSES processes now all Correction objects from PSSA but the message specifically was just taken from the last correction here. I did not notice this at first because I thought I had to tweak my rule first to emit two different messages until I realized it was another bug in PSES. Related: PowerShell/PSScriptAnalyzer#1782 Co-authored-by: Andy Schwartzmeyer <andrew@schwartzmeyer.com>
Currently, PSSA's
SuggestCorrections
property of theDiagnosticRecord
object already is an array, but no built-in rulesreturn more than one suggested correction, which led to
PowerShellEditorServices
not correctly translating this array beforereturning it as an code action as it only ever displayed one. This fixes
it by making it generic again so it returns a code action for each
suggest correction. It's basically just performing a
foreach
loop andcalling
ToTextEdit
just once.This is a pre-requisite for an implementation of this, where a built-in
rule will return multiple suggest corrections:
PowerShell/PSScriptAnalyzer#1767
I've manually tested this with a modified version of PSScriptAnalyzer
where I return two suggested corrections. The extension's UI now shows
me the two different suggested code actions and also applies them
correctly.
Replaces #1713.