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

Commit3ad6242

Browse files
[release/v7.5] Remove the old fuzzy suggestion and fix the local script file name suggestion (#25330)
Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
1 parent2bab6df commit3ad6242

File tree

5 files changed

+16
-32
lines changed

5 files changed

+16
-32
lines changed

‎src/System.Management.Automation/engine/Subsystem/FeedbackSubsystem/IFeedbackProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ internal GeneralCommandErrorFeedback()
243243

244244
publicGuidId=>_guid;
245245

246-
publicstringName=>"general";
246+
publicstringName=>"General Feedback";
247247

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

‎src/System.Management.Automation/engine/hostifaces/HostUtilities.cs

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
usingSystem.Globalization;
99
usingSystem.Management.Automation.Host;
1010
usingSystem.Management.Automation.Internal;
11-
usingSystem.Management.Automation.Language;
1211
usingSystem.Management.Automation.Runspaces;
1312
usingSystem.Management.Automation.Subsystem.Feedback;
1413
usingSystem.Runtime.InteropServices;
@@ -67,13 +66,6 @@ public static class HostUtilities
6766
$formatString -f $lastError.TargetObject,"".\$($lastError.TargetObject)""
6867
";
6968

70-
privatestaticreadonlystrings_getFuzzyMatchedCommands=@"
71-
[System.Diagnostics.DebuggerHidden()]
72-
param([string] $formatString)
73-
74-
$formatString -f [string]::Join(', ', (Get-Command $lastError.TargetObject -UseFuzzyMatching -FuzzyMinimumDistance 1 | Select-Object -First 5 -Unique -ExpandProperty Name))
75-
";
76-
7769
privatestaticreadonlyList<Hashtable>s_suggestions=InitializeSuggestions();
7870

7971
privatestaticboolHostSupportUnicode()
@@ -97,28 +89,17 @@ private static bool HostSupportUnicode()
9789

9890
privatestaticList<Hashtable>InitializeSuggestions()
9991
{
100-
varsuggestions=newList<Hashtable>(
101-
newHashtable[]
102-
{
103-
NewSuggestion(
104-
id:3,
105-
category:"General",
106-
matchType:SuggestionMatchType.Dynamic,
107-
rule:ScriptBlock.CreateDelayParsedScriptBlock(s_checkForCommandInCurrentDirectoryScript,isProductCode:true),
108-
suggestion:ScriptBlock.CreateDelayParsedScriptBlock(s_createCommandExistsInCurrentDirectoryScript,isProductCode:true),
109-
suggestionArgs:newobject[]{CodeGeneration.EscapeSingleQuotedStringContent(SuggestionStrings.Suggestion_CommandExistsInCurrentDirectory)},
110-
enabled:true)
111-
});
112-
113-
suggestions.Add(
92+
varsuggestions=newList<Hashtable>()
93+
{
11494
NewSuggestion(
115-
id:4,
95+
id:3,
11696
category:"General",
117-
matchType:SuggestionMatchType.ErrorId,
118-
rule:"CommandNotFoundException",
119-
suggestion:ScriptBlock.CreateDelayParsedScriptBlock(s_getFuzzyMatchedCommands,isProductCode:true),
120-
suggestionArgs:newobject[]{CodeGeneration.EscapeSingleQuotedStringContent(SuggestionStrings.Suggestion_CommandNotFound)},
121-
enabled:true));
97+
matchType:SuggestionMatchType.Dynamic,
98+
rule:ScriptBlock.CreateDelayParsedScriptBlock(s_checkForCommandInCurrentDirectoryScript,isProductCode:true),
99+
suggestion:ScriptBlock.CreateDelayParsedScriptBlock(s_createCommandExistsInCurrentDirectoryScript,isProductCode:true),
100+
suggestionArgs:newobject[]{SuggestionStrings.Suggestion_CommandExistsInCurrentDirectory_Legacy},
101+
enabled:true)
102+
};
122103

123104
returnsuggestions;
124105
}

‎src/System.Management.Automation/resources/SuggestionStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ PowerShell does not load commands from the current location by default (see 'Get
123123

124124
If you trust this command, run the following command instead:</value>
125125
</data>
126+
<dataname="Suggestion_CommandExistsInCurrentDirectory_Legacy"xml:space="preserve">
127+
<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>
128+
</data>
126129
<dataname="Suggestion_CommandNotFound"xml:space="preserve">
127130
<value>The most similar commands are:</value>
128131
</data>

‎src/System.Management.Automation/utils/Telemetry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static ApplicationInsightsTelemetry()
635635
s_knownSubsystemNames=newHashSet<string>(StringComparer.OrdinalIgnoreCase)
636636
{
637637
"Completion",
638-
"general",
638+
"General Feedback",
639639
"Windows Package Manager - WinGet",
640640
"Az Predictor"
641641
};

‎test/xUnit/csharp/test_Feedback.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static void GetFeedback()
9797

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

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

109109
FeedbackResultentry1=feedbacks[0];
110-
Assert.Equal("general",entry1.Name);
110+
Assert.Equal("General Feedback",entry1.Name);
111111
Assert.Equal(expectedCmd,entry1.Item.RecommendedActions[0]);
112112

113113
FeedbackResultentry2=feedbacks[1];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp