瀏覽代碼

Merge pull request #139 from spahnke/regexp-match-indices

[JS/TS] Add support for the RegExp Match Indices flag
Henning Dieterichs 4 年之前
父節點
當前提交
6148b8a130
共有 3 個文件被更改,包括 4 次插入4 次删除
  1. 1 1
      src/javascript/javascript.test.ts
  2. 1 1
      src/typescript/typescript.test.ts
  3. 2 2
      src/typescript/typescript.ts

+ 1 - 1
src/javascript/javascript.test.ts

@@ -652,7 +652,7 @@ testTokenization('javascript', [
 
 
 	[
 	[
 		{
 		{
-			line: '/foo/gimsuy',
+			line: '/foo/dgimsuy',
 			tokens: [
 			tokens: [
 				{ startIndex: 0, type: 'regexp.js' },
 				{ startIndex: 0, type: 'regexp.js' },
 				{ startIndex: 5, type: 'keyword.other.js' }
 				{ startIndex: 5, type: 'keyword.other.js' }

+ 1 - 1
src/typescript/typescript.test.ts

@@ -674,7 +674,7 @@ testTokenization('typescript', [
 
 
 	[
 	[
 		{
 		{
-			line: '/foo/gimsuy',
+			line: '/foo/dgimsuy',
 			tokens: [
 			tokens: [
 				{ startIndex: 0, type: 'regexp.ts' },
 				{ startIndex: 0, type: 'regexp.ts' },
 				{ startIndex: 5, type: 'keyword.other.ts' }
 				{ startIndex: 5, type: 'keyword.other.ts' }

+ 2 - 2
src/typescript/typescript.ts

@@ -240,7 +240,7 @@ export const language = {
 
 
 			// regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
 			// regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
 			[
 			[
-				/\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
+				/\/(?=([^\\\/]|\\.)+\/([dgimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
 				{ token: 'regexp', bracket: '@open', next: '@regexp' }
 				{ token: 'regexp', bracket: '@open', next: '@regexp' }
 			],
 			],
 
 
@@ -313,7 +313,7 @@ export const language = {
 			[/@regexpesc/, 'regexp.escape'],
 			[/@regexpesc/, 'regexp.escape'],
 			[/\\\./, 'regexp.invalid'],
 			[/\\\./, 'regexp.invalid'],
 			[
 			[
-				/(\/)([gimsuy]*)/,
+				/(\/)([dgimsuy]*)/,
 				[{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']
 				[{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']
 			]
 			]
 		],
 		],