瀏覽代碼

Fixes Microsoft/monaco-editor#1224

Alex Dima 6 年之前
父節點
當前提交
8f7537dee5
共有 2 個文件被更改,包括 21 次插入0 次删除
  1. 20 0
      src/typescript/typescript.test.ts
  2. 1 0
      src/typescript/typescript.ts

+ 20 - 0
src/typescript/typescript.test.ts

@@ -481,6 +481,26 @@ testTokenization('typescript', [
 		]
 	}],
 
+	[{
+		line: 'var x = !/`/.test(\'a\');',
+		tokens: [
+			{ startIndex: 0, type: 'keyword.ts' },
+			{ startIndex: 3, type: '' },
+			{ startIndex: 4, type: 'identifier.ts' },
+			{ startIndex: 5, type: '' },
+			{ startIndex: 6, type: 'delimiter.ts' },
+			{ startIndex: 7, type: '' },
+			{ startIndex: 8, type: 'delimiter.ts' },
+			{ startIndex: 9, type: 'regexp.ts' },
+			{ startIndex: 12, type: 'delimiter.ts' },
+			{ startIndex: 13, type: 'identifier.ts' },
+			{ startIndex: 17, type: 'delimiter.parenthesis.ts' },
+			{ startIndex: 18, type: 'string.ts' },
+			{ startIndex: 21, type: 'delimiter.parenthesis.ts' },
+			{ startIndex: 22, type: 'delimiter.ts' },
+		]
+	}],
+
 	[{
 		line: '/foo/',
 		tokens: [

+ 1 - 0
src/typescript/typescript.ts

@@ -135,6 +135,7 @@ export const language = {
 			// delimiters and operators
 			[/[()\[\]]/, '@brackets'],
 			[/[<>](?!@symbols)/, '@brackets'],
+			[/!(?=([^=]|$))/, 'delimiter'],
 			[/@symbols/, {
 				cases: {
 					'@operators': 'delimiter',