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

Commita8d8dc3

Browse files
ArmaanMcleodiSazonov
authored andcommitted
Use internal HandleDoubleAndSingleQuote method to do quoting
1 parent6213c6a commita8d8dc3

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

‎src/Microsoft.PowerShell.Commands.Management/commands/management/NewPropertyCommand.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,6 @@ public class PropertyTypeArgumentCompleter : IArgumentCompleter
211211
_=>TabCompletionStrings.RegistryUnknownToolTip
212212
};
213213

214-
privatestaticreadonlychar[]QuoteChars=newchar[]
215-
{
216-
'\'',
217-
'"',
218-
'\u2018',// left single quotation mark
219-
'\u2019',// right single quotation mark
220-
'\u201a',// single low-9 quotation mark
221-
'\u201b',// single high-reversed-9 quotation mark
222-
'\u201c',// left double quotation mark
223-
'\u201d',// right double quotation mark
224-
'\u201E'// low double left quote used in german
225-
};
226-
227214
/// <summary>
228215
/// Returns completion results for PropertyType parameter.
229216
/// </summary>
@@ -245,14 +232,19 @@ public IEnumerable<CompletionResult> CompleteArgument(
245232
yieldbreak;
246233
}
247234

248-
varpropertyTypePattern=WildcardPattern.Get(wordToComplete.Trim(QuoteChars)+"*",WildcardOptions.IgnoreCase);
235+
stringquote=CompletionCompleters.HandleDoubleAndSingleQuote(refwordToComplete);
236+
varpropertyTypePattern=WildcardPattern.Get(wordToComplete+"*",WildcardOptions.IgnoreCase);
249237

250238
foreach(stringpropertyTypeins_RegistryPropertyTypes)
251239
{
252240
if(propertyTypePattern.IsMatch(propertyType))
253241
{
242+
stringcompletionText=quote==string.Empty
243+
?propertyType
244+
:quote+propertyType+quote;
245+
254246
yieldreturnnewCompletionResult(
255-
propertyType,
247+
completionText,
256248
propertyType,
257249
CompletionResultType.ParameterValue,
258250
GetRegistryPropertyTypeToolTip(propertyType));

‎test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ ConstructorTestClass(int i, bool b)
935935
BeforeAll {
936936
if ($IsWindows) {
937937
$allRegistryValueKinds='String ExpandString Binary DWord MultiString QWord Unknown'
938+
$allRegistryValueKindsWithQuotes="'String' 'ExpandString' 'Binary' 'DWord' 'MultiString' 'QWord' 'Unknown'"
938939
$dwordValueKind='DWord'
939940
$qwordValueKind='QWord'
940941
$binaryValueKind='Binary'
@@ -979,8 +980,8 @@ ConstructorTestClass(int i, bool b)
979980
@{TextInput="New-ItemProperty -PropertyType invalidproptype";ExpectedPropertyTypes='' }
980981

981982
# All of these should return completion even with quotes included
982-
@{TextInput="New-ItemProperty -Path$registryPath -PropertyType '";ExpectedPropertyTypes=$allRegistryValueKinds }
983-
@{TextInput="New-ItemProperty -Path$registryPath -PropertyType 'bin";ExpectedPropertyTypes=$binaryValueKind }
983+
@{TextInput="New-ItemProperty -Path$registryPath -PropertyType '";ExpectedPropertyTypes=$allRegistryValueKindsWithQuotes }
984+
@{TextInput="New-ItemProperty -Path$registryPath -PropertyType 'bin";ExpectedPropertyTypes="'$binaryValueKind'" }
984985
) {
985986
param($TextInput,$ExpectedPropertyTypes)
986987
$res= TabExpansion2-inputScript$TextInput-cursorColumn$TextInput.Length

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp