Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove the old fuzzy suggestion and fix the local script file name suggestion#25177

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
daxian-dbw merged 2 commits intoPowerShell:masterfromdaxian-dbw:fuzzy
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -243,7 +243,7 @@ internal GeneralCommandErrorFeedback()

publicGuidId=>_guid;

publicstringName=>"general";
publicstringName=>"General Feedback";

publicstringDescription=>"The built-in general feedback source for command errors.";

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@
using System.Globalization;
using System.Management.Automation.Host;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Subsystem.Feedback;
using System.Runtime.InteropServices;
Expand DownExpand Up@@ -67,13 +66,6 @@ public static class HostUtilities
$formatString -f $lastError.TargetObject,"".\$($lastError.TargetObject)""
";

private static readonly string s_getFuzzyMatchedCommands = @"
[System.Diagnostics.DebuggerHidden()]
param([string] $formatString)

$formatString -f [string]::Join(', ', (Get-Command $lastError.TargetObject -UseFuzzyMatching -FuzzyMinimumDistance 1 | Select-Object -First 5 -Unique -ExpandProperty Name))
";

private static readonly List<Hashtable> s_suggestions = InitializeSuggestions();

private static bool HostSupportUnicode()
Expand All@@ -97,28 +89,17 @@ private static bool HostSupportUnicode()

private static List<Hashtable> InitializeSuggestions()
{
var suggestions = new List<Hashtable>(
new Hashtable[]
{
NewSuggestion(
id: 3,
category: "General",
matchType: SuggestionMatchType.Dynamic,
rule: ScriptBlock.CreateDelayParsedScriptBlock(s_checkForCommandInCurrentDirectoryScript, isProductCode: true),
suggestion: ScriptBlock.CreateDelayParsedScriptBlock(s_createCommandExistsInCurrentDirectoryScript, isProductCode: true),
suggestionArgs: new object[] { CodeGeneration.EscapeSingleQuotedStringContent(SuggestionStrings.Suggestion_CommandExistsInCurrentDirectory) },
enabled: true)
});

suggestions.Add(
var suggestions = new List<Hashtable>()
{
NewSuggestion(
id:4,
id:3,
category: "General",
matchType: SuggestionMatchType.ErrorId,
rule: "CommandNotFoundException",
suggestion: ScriptBlock.CreateDelayParsedScriptBlock(s_getFuzzyMatchedCommands, isProductCode: true),
suggestionArgs: new object[] { CodeGeneration.EscapeSingleQuotedStringContent(SuggestionStrings.Suggestion_CommandNotFound) },
enabled: true));
matchType: SuggestionMatchType.Dynamic,
rule: ScriptBlock.CreateDelayParsedScriptBlock(s_checkForCommandInCurrentDirectoryScript, isProductCode: true),
suggestion: ScriptBlock.CreateDelayParsedScriptBlock(s_createCommandExistsInCurrentDirectoryScript, isProductCode: true),
suggestionArgs: new object[] { SuggestionStrings.Suggestion_CommandExistsInCurrentDirectory_Legacy },
enabled: true)
};

return suggestions;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,6 +123,9 @@ PowerShell does not load commands from the current location by default (see 'Get

If you trust this command, run the following command instead:</value>
</data>
<dataname="Suggestion_CommandExistsInCurrentDirectory_Legacy"xml:space="preserve">
<value>The command "{0}" was not found, but does exist in the current location. PowerShell does not load commands from the current location by default. If you trust this command, instead type: "{1}". See "get-help about_Command_Precedence" for more details.</value>
</data>
<dataname="Suggestion_CommandNotFound"xml:space="preserve">
<value>The most similar commands are:</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletionsrc/System.Management.Automation/utils/Telemetry.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -636,7 +636,7 @@ static ApplicationInsightsTelemetry()
s_knownSubsystemNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"Completion",
"general",
"General Feedback",
"Windows Package Manager - WinGet",
"Az Predictor"
};
Expand Down
4 changes: 2 additions & 2 deletionstest/xUnit/csharp/test_Feedback.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,7 +97,7 @@ public static void GetFeedback()

// Test the result from the 'general' feedback provider.
Assert.Single(feedbacks);
Assert.Equal("general", feedbacks[0].Name);
Assert.Equal("General Feedback", feedbacks[0].Name);
Assert.Equal(expectedCmd, feedbacks[0].Item.RecommendedActions[0]);

// Expect the result from both 'general' and the 'slow' feedback providers.
Expand All@@ -107,7 +107,7 @@ public static void GetFeedback()
Assert.Equal(2, feedbacks.Count);

FeedbackResult entry1 = feedbacks[0];
Assert.Equal("general", entry1.Name);
Assert.Equal("General Feedback", entry1.Name);
Assert.Equal(expectedCmd, entry1.Item.RecommendedActions[0]);

FeedbackResult entry2 = feedbacks[1];
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp