Skip to content

Commit 6dee015

Browse files
committed
fix issue #983
Do not adjust userCompletionText while finding userCompletion text position when match contains `{` in CompletionText[1], and preserve the splat sigil at start of completions of type `Variable`. Adjusting userCompletionText led to selection box consuming sigil for braced variables, or crash on incorrectly braced splats.
1 parent b7b8f7b commit 6dee015

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

PSReadLine/Completion.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/********************************************************************++
1+
/********************************************************************++
22
Copyright (c) Microsoft Corporation. All rights reserved.
33
--********************************************************************/
44

@@ -106,7 +106,7 @@ private static string GetUnquotedText(CompletionResult match, bool consistentQuo
106106
{
107107
if (IsQuotedVariable(s))
108108
{
109-
return '$' + s.Substring(2, s.Length - 3);
109+
return s[0] + s.Substring(2, s.Length - 3);
110110
}
111111
return s;
112112
}
@@ -731,9 +731,7 @@ private Collection<CompletionResult> FilterCompletions(CommandCompletion complet
731731

732732
private int FindUserCompletionTextPosition(CompletionResult match, string userCompletionText)
733733
{
734-
return match.ResultType == CompletionResultType.Variable && match.CompletionText[1] == '{'
735-
? match.CompletionText.IndexOf(userCompletionText.Substring(1), StringComparison.OrdinalIgnoreCase) - 1
736-
: match.CompletionText.IndexOf(userCompletionText, StringComparison.OrdinalIgnoreCase);
734+
return match.CompletionText.IndexOf(userCompletionText, StringComparison.OrdinalIgnoreCase);
737735
}
738736

739737
private bool IsDoneWithCompletions(CompletionResult currentCompletion, PSKeyInfo nextKey)

0 commit comments

Comments
 (0)