diff --git a/PSReadLine/Completion.cs b/PSReadLine/Completion.cs index 0397c84ec..b24d58198 100644 --- a/PSReadLine/Completion.cs +++ b/PSReadLine/Completion.cs @@ -106,7 +106,7 @@ private static string GetUnquotedText(CompletionResult match, bool consistentQuo { if (IsQuotedVariable(s)) { - return '$' + s.Substring(2, s.Length - 3); + return s[0] + s.Substring(2, s.Length - 3); } return s; } @@ -731,7 +731,7 @@ private Collection FilterCompletions(CommandCompletion complet private int FindUserCompletionTextPosition(CompletionResult match, string userCompletionText) { - return match.ResultType == CompletionResultType.Variable && match.CompletionText[1] == '{' + return match.ResultType == CompletionResultType.Variable && userCompletionText.Length > 1 && match.CompletionText[1] == '{' ? match.CompletionText.IndexOf(userCompletionText.Substring(1), StringComparison.OrdinalIgnoreCase) - 1 : match.CompletionText.IndexOf(userCompletionText, StringComparison.OrdinalIgnoreCase); }