Skip to content

Commit 3bbcc92

Browse files
get test working
1 parent 65bd07f commit 3bbcc92

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
8686
string diagnosticId = AnalysisService.GetUniqueIdFromDiagnostic(diagnostic);
8787
if (corrections.TryGetValue(diagnosticId, out MarkerCorrection correction))
8888
{
89-
9089
codeActions.Add(new CodeAction
9190
{
9291
Title = correction.Name,
@@ -120,10 +119,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
120119
!ruleNamesProcessed.Contains(diagnostic.Code.String))
121120
{
122121
ruleNamesProcessed.Add(diagnostic.Code.String);
123-
124-
// This should always be a string but just in case, we fall back to the Long value.
125-
var code = diagnostic.Code.IsString ? diagnostic.Code.String : diagnostic.Code.Long.ToString();
126-
var title = $"Show documentation for: {code}";
122+
var title = $"Show documentation for: {diagnostic.Code.String}";
127123
codeActions.Add(new CodeAction
128124
{
129125
Title = title,
@@ -135,7 +131,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
135131
{
136132
Title = title,
137133
Name = "PowerShell.ShowCodeActionDocumentation",
138-
Arguments = JArray.FromObject(new[] { code })
134+
Arguments = JArray.FromObject(new[] { diagnostic.Code.String })
139135
}
140136
});
141137
}

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,18 @@ await LanguageClient.SendRequest<CommandOrCodeActionContainer>(
669669
command =>
670670
{
671671
Assert.Equal(
672-
"'gci' is an alias of 'Get-ChildItem'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.PSScriptAnalyzer(PSAvoidUsingCmdletAliases)",
672+
"Replace gci with Get-ChildItem",
673673
command.CodeAction.Title);
674674
Assert.Equal(
675-
CodeActionKind.QuickFix,
676-
command.CodeAction.Kind);
675+
CodeActionKind.QuickFix.Kind,
676+
command.CodeAction.Kind.Kind);
677677
Assert.Single(command.CodeAction.Edit.DocumentChanges);
678+
},
679+
command =>
680+
{
681+
Assert.Equal(
682+
"PowerShell.ShowCodeActionDocumentation",
683+
command.CodeAction.Command.Name);
678684
});
679685
}
680686

0 commit comments

Comments
 (0)