فهرست منبع

Fixes Microsoft/monaco-editor#1175

Alex Dima 6 سال پیش
والد
کامیت
ad77f86a8c
2فایلهای تغییر یافته به همراه31 افزوده شده و 5 حذف شده
  1. 9 0
      src/shell/shell.test.ts
  2. 22 5
      src/shell/shell.ts

+ 9 - 0
src/shell/shell.test.ts

@@ -279,4 +279,13 @@ testTokenization('shell', [
 			{ startIndex: 4, type: 'string.heredoc.shell' }
 		]
 	}],
+
+	[{
+		line: 'echo $( echo "hi" )',
+		tokens: [
+			{ startIndex: 0, type: 'type.identifier.shell' },
+			{ startIndex: 4, type: 'white.shell' },
+			{ startIndex: 5, type: 'variable.shell' }
+		]
+	}],
 ])

+ 22 - 5
src/shell/shell.ts

@@ -201,13 +201,30 @@ export const language = <ILanguage>{
 			[/\$\d+/, 'variable.predefined'],
 			[/\$\w+/, 'variable'],
 			[/\$[*@#?\-$!0_]/, 'variable'],
-			[/\$['"{(]/, 'variable', '@parameterBody']
+			[/\$'/, 'variable', '@parameterBodyQuote'],
+			[/\$"/, 'variable', '@parameterBodyDoubleQuote'],
+			[/\$\(/, 'variable', '@parameterBodyParen'],
+			[/\$\{/, 'variable', '@parameterBodyCurlyBrace'],
 		],
-
-		parameterBody: [
+		parameterBodyQuote: [
+			[/[^#:%*@\-!_']+/, 'variable'],
+			[/[#:%*@\-!_]/, 'delimiter'],
+			[/[']/, 'variable', '@pop'],
+		],
+		parameterBodyDoubleQuote: [
+			[/[^#:%*@\-!_"]+/, 'variable'],
+			[/[#:%*@\-!_]/, 'delimiter'],
+			[/["]/, 'variable', '@pop'],
+		],
+		parameterBodyParen: [
+			[/[^#:%*@\-!_)]+/, 'variable'],
+			[/[#:%*@\-!_]/, 'delimiter'],
+			[/[)]/, 'variable', '@pop'],
+		],
+		parameterBodyCurlyBrace: [
+			[/[^#:%*@\-!_}]+/, 'variable'],
 			[/[#:%*@\-!_]/, 'delimiter'],
-			[/['"{(]/, 'variable', '@pop'],
-			[/./, 'variable']
+			[/[}]/, 'variable', '@pop'],
 		],
 	}
 };