Skip to content

Commit 0431a90

Browse files
get test working
1 parent 329def0 commit 0431a90

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
@@ -87,7 +87,6 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
8787
string diagnosticId = AnalysisService.GetUniqueIdFromDiagnostic(diagnostic);
8888
if (corrections.TryGetValue(diagnosticId, out MarkerCorrection correction))
8989
{
90-
9190
codeActions.Add(new CodeAction
9291
{
9392
Title = correction.Name,
@@ -121,10 +120,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
121120
!ruleNamesProcessed.Contains(diagnostic.Code.String))
122121
{
123122
ruleNamesProcessed.Add(diagnostic.Code.String);
124-
125-
// This should always be a string but just in case, we fall back to the Long value.
126-
var code = diagnostic.Code.IsString ? diagnostic.Code.String : diagnostic.Code.Long.ToString();
127-
var title = $"Show documentation for: {code}";
123+
var title = $"Show documentation for: {diagnostic.Code.String}";
128124
codeActions.Add(new CodeAction
129125
{
130126
Title = title,
@@ -136,7 +132,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
136132
{
137133
Title = title,
138134
Name = "PowerShell.ShowCodeActionDocumentation",
139-
Arguments = JArray.FromObject(new[] { code })
135+
Arguments = JArray.FromObject(new[] { diagnostic.Code.String })
140136
}
141137
});
142138
}

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)