Skip to content

Commit 8f21759

Browse files
working
1 parent 40de314 commit 8f21759

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
8989

9090
codeActions.Add(new CodeAction
9191
{
92+
Title = correction.Name,
9293
Kind = CodeActionKind.QuickFix,
94+
Diagnostics = new Container<Diagnostic>(diagnostic),
9395
Command = new Command
9496
{
9597
Title = correction.Name,
@@ -113,13 +115,21 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
113115
{
114116
ruleNamesProcessed.Add(diagnostic.Code.String);
115117

118+
// This should always be a string but just in case, we fall back to the Long value.
119+
var code = diagnostic.Code.IsString ? diagnostic.Code.String : diagnostic.Code.Long.ToString();
120+
var title = $"Show documentation for: {code}";
116121
codeActions.Add(new CodeAction
117122
{
123+
Title = title,
124+
// This doesn't fix anything, but I'm adding it here so that it shows up in VS Code's
125+
// Quick fix UI. The VS Code team is working on a way to support documentation CodeAction's better
126+
// but this is good for now until that's ready.
127+
Kind = CodeActionKind.QuickFix,
118128
Command = new Command
119129
{
120-
Title = $"Show documentation for \"{diagnostic.Code}\"",
130+
Title = title,
121131
Name = "PowerShell.ShowCodeActionDocumentation",
122-
Arguments = JArray.FromObject(new[] { diagnostic.Code })
132+
Arguments = JArray.FromObject(new[] { code })
123133
}
124134
});
125135
}

0 commit comments

Comments
 (0)