@@ -4789,6 +4789,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
4789
4789
var lastAst = context . RelatedAsts ? . Last ( ) ;
4790
4790
var variableAst = lastAst as VariableExpressionAst ;
4791
4791
var prefix = variableAst != null && variableAst . Splatted ? "@" : "$" ;
4792
+ bool tokenAtCursorUsedBraces = context . TokenAtCursor is not null && context . TokenAtCursor . Text . StartsWith ( "${" ) ;
4792
4793
4793
4794
// Look for variables in the input (e.g. parameters, etc.) before checking session state - these
4794
4795
// variables might not exist in session state yet.
@@ -4934,7 +4935,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
4934
4935
}
4935
4936
}
4936
4937
4937
- var completedName = ( name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4938
+ var completedName = ( ! tokenAtCursorUsedBraces && name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4938
4939
? prefix + provider + name
4939
4940
: prefix + "{" + provider + name + "}" ;
4940
4941
AddUniqueVariable ( hashedResults , results , completedName , name , tooltip ) ;
@@ -4957,7 +4958,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
4957
4958
if ( ! string . IsNullOrEmpty ( name ) )
4958
4959
{
4959
4960
name = "env:" + name ;
4960
- var completedName = ( name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4961
+ var completedName = ( ! tokenAtCursorUsedBraces && name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4961
4962
? prefix + name
4962
4963
: prefix + "{" + name + "}" ;
4963
4964
AddUniqueVariable ( hashedResults , results , completedName , name , "[string]" + name ) ;
@@ -4972,7 +4973,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
4972
4973
{
4973
4974
if ( wildcardPattern . IsMatch ( specialVariable ) )
4974
4975
{
4975
- var completedName = ( specialVariable . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4976
+ var completedName = ( ! tokenAtCursorUsedBraces && specialVariable . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
4976
4977
? prefix + specialVariable
4977
4978
: prefix + "{" + specialVariable + "}" ;
4978
4979
@@ -4998,7 +4999,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
4998
4999
var name = driveInfo . Name ;
4999
5000
if ( name != null && ! string . IsNullOrWhiteSpace ( name ) && name . Length > 1 )
5000
5001
{
5001
- var completedName = ( name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
5002
+ var completedName = ( ! tokenAtCursorUsedBraces && name . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
5002
5003
? prefix + name + ":"
5003
5004
: prefix + "{" + name + ":}" ;
5004
5005
@@ -5014,7 +5015,7 @@ internal static List<CompletionResult> CompleteVariable(CompletionContext contex
5014
5015
{
5015
5016
if ( scopePattern . IsMatch ( scope ) )
5016
5017
{
5017
- var completedName = ( scope . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
5018
+ var completedName = ( ! tokenAtCursorUsedBraces && scope . IndexOfAny ( s_charactersRequiringQuotes ) == - 1 )
5018
5019
? prefix + scope
5019
5020
: prefix + "{" + scope + "}" ;
5020
5021
AddUniqueVariable ( hashedResults , results , completedName , scope , scope ) ;
0 commit comments