Skip to content

Commit bef2cf6

Browse files
authored
Update to use the new interface (#4)
1 parent e783875 commit bef2cf6

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/FeedbackProvider.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ static bool IsFileExecutable(string path)
4646
}
4747
}
4848

49-
public FeedbackItem? GetFeedback(string commandLine, ErrorRecord lastError, CancellationToken token)
49+
public FeedbackItem? GetFeedback(FeedbackContext context, CancellationToken token)
5050
{
51-
if (Platform.IsWindows || lastError.FullyQualifiedErrorId != "CommandNotFoundException")
51+
if (Platform.IsWindows)
5252
{
5353
return null;
5454
}
5555

56-
var target = (string)lastError.TargetObject;
57-
if (target is null)
58-
{
59-
return null;
60-
}
61-
62-
if (target.EndsWith(".ps1", StringComparison.OrdinalIgnoreCase))
56+
// Use the different trigger 'CommandNotFound', so 'LastError' won't be null.
57+
var target = (string)context.LastError!.TargetObject;
58+
if (target is null || target.EndsWith(".ps1", StringComparison.OrdinalIgnoreCase))
6359
{
6460
return null;
6561
}

src/PowerShell.CommandNotFound.Feedback.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="System.Management.Automation" Version="7.4.0-preview.2">
23+
<PackageReference Include="System.Management.Automation" Version="7.4.0-preview.3">
2424
<ExcludeAssets>contentFiles</ExcludeAssets>
2525
<PrivateAssets>All</PrivateAssets>
2626
</PackageReference>

0 commit comments

Comments
 (0)