Skip to content

Commit 70d0d34

Browse files
committed
fix issue #983
Prevent adjustment of userCompletionText while finding userCompletion text position when match contains `{` in CompletionText[1] if the userCompletionText is not longer than 1 char, and preserve the splat sigil at start of completions of type `Variable`. Adjusting userCompletionText blindly led to ArgumentOutOfRangeException on incorrectly braced splats on input `@?`.
1 parent b7b8f7b commit 70d0d34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PSReadLine/Completion.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +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] == '{'
734+
return match.ResultType == CompletionResultType.Variable && userCompletionText.Length > 1 && match.CompletionText[1] == '{'
735735
? match.CompletionText.IndexOf(userCompletionText.Substring(1), StringComparison.OrdinalIgnoreCase) - 1
736736
: match.CompletionText.IndexOf(userCompletionText, StringComparison.OrdinalIgnoreCase);
737737
}

0 commit comments

Comments
 (0)