File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -85,15 +85,33 @@ class Syntax {
8585 ```
8686 **/
8787 public static macro function dollar (identifier : Expr ): Expr {
88- final identifier = switch (identifier .expr ) {
88+ var identifier = switch (identifier .expr ) {
8989 case EConst (CString (s , _ ) | CIdent (s )): s ;
9090 case _ : {
9191 Context .error (" Expected String or identifier expression" , identifier .pos );
9292 return macro {};
9393 }
9494 }
9595
96- final identifier = " $" + identifier ;
96+ // Check if the input content contains a space.
97+ final hasSpace = {
98+ var result = false ;
99+ final len = identifier .length ;
100+ for (i in 0 ... len ) {
101+ if (StringTools .isSpace (identifier , i )) {
102+ result = true ;
103+ break ;
104+ }
105+ }
106+ result ;
107+ }
108+
109+ // Wrap with quotes if the identifier has a space.
110+ if (hasSpace ) {
111+ identifier = ' " ${identifier }"' ;
112+ }
113+
114+ identifier = " $" + identifier ;
97115 return macro untyped __gdscript__ ($v {identifier });
98116 }
99117}
You can’t perform that action at this time.
0 commit comments