Browse Source

Fixes microsoft/monaco-editor#1708

Alex Dima 5 years ago
parent
commit
8267281d21
5 changed files with 47 additions and 8 deletions
  1. 4 4
      package-lock.json
  2. 1 1
      package.json
  3. 32 2
      src/kotlin/kotlin.test.ts
  4. 9 0
      src/kotlin/kotlin.ts
  5. 1 1
      test/all.js

+ 4 - 4
package-lock.json

@@ -84,7 +84,7 @@
     },
     "array-equal": {
       "version": "1.0.0",
-      "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
+      "resolved": "http://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
       "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=",
       "dev": true
     },
@@ -938,9 +938,9 @@
       }
     },
     "monaco-editor-core": {
-      "version": "0.18.1",
-      "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.18.1.tgz",
-      "integrity": "sha512-euzXzmwjZFG0oAPGjICMwINcZBzQDyfGDYlAR5YNMBJZO9Bmkqq1xpTTze/qQ0KKbVmawFXiwgUbg7WVgebP9Q==",
+      "version": "0.19.0",
+      "resolved": "https://registry.npmjs.org/monaco-editor-core/-/monaco-editor-core-0.19.0.tgz",
+      "integrity": "sha512-wD60zpYDhsuJbzzLQigAteK2cA5fkuaDn+4c7NLwm/526OX5eL6MMvLhfvRgrDvLO00SYhFf6vz1y1C8M1hTpQ==",
       "dev": true
     },
     "monaco-plugin-helpers": {

+ 1 - 1
package.json

@@ -21,7 +21,7 @@
     "glob": "^7.1.6",
     "jsdom": "^15.2.1",
     "mocha": "^6.2.2",
-    "monaco-editor-core": "0.18.1",
+    "monaco-editor-core": "0.19.0",
     "monaco-plugin-helpers": "^1.0.2",
     "requirejs": "^2.3.6",
     "terser": "^4.4.3",

+ 32 - 2
src/kotlin/kotlin.test.ts

@@ -670,6 +670,36 @@ testTokenization('kotlin', [
 			{ startIndex: 22, type: '' },
 			{ startIndex: 23, type: 'delimiter.curly.kt' },
 		]
-	}]
-]);
+	}],
 
+	[{
+		line: 'val text = """',
+		tokens: [
+			{ startIndex: 0, type: 'keyword.val.kt' },
+			{ startIndex: 3, type: '' },
+			{ startIndex: 4, type: 'identifier.kt' },
+			{ startIndex: 8, type: '' },
+			{ startIndex: 9, type: 'delimiter.kt' },
+			{ startIndex: 10, type: '' },
+			{ startIndex: 11, type: 'string.kt' },
+		]
+	},
+	{
+		line: '    for (c in "foo")',
+		tokens: [
+			{ startIndex: 0, type: 'string.kt' },
+		]
+	},
+	{
+		line: '        print(c)',
+		tokens: [
+			{ startIndex: 0, type: 'string.kt' },
+		]
+	},
+	{
+		line: '"""',
+		tokens: [
+			{ startIndex: 0, type: 'string.kt' },
+		]
+	}],
+]);

+ 9 - 0
src/kotlin/kotlin.ts

@@ -119,6 +119,7 @@ export const language = <ILanguage>{
 
 			// strings
 			[/"([^"\\]|\\.)*$/, 'string.invalid'],  // non-teminated string
+			[/"""/, 'string', '@multistring'],
 			[/"/, 'string', '@string'],
 
 			// characters
@@ -155,5 +156,13 @@ export const language = <ILanguage>{
 			[/\\./, 'string.escape.invalid'],
 			[/"/, 'string', '@pop']
 		],
+
+		multistring: [
+			[/[^\\"]+/, 'string'],
+			[/@escapes/, 'string.escape'],
+			[/\\./, 'string.escape.invalid'],
+			[/"""/, 'string', '@pop'],
+			[/./, 'string']
+		],
 	},
 };

+ 1 - 1
test/all.js

@@ -18,7 +18,7 @@ global.document = tmp.window.document;
 global.navigator = tmp.window.navigator;
 global.self = global;
 global.document.queryCommandSupported = function () { return false; };
-global.window = { location: {} };
+global.window = { location: {}, navigator: tmp.window.navigator };
 
 requirejs(['./test/setup'], function () {
 	glob('release/dev/*/*.test.js', { cwd: path.dirname(__dirname) }, function (err, files) {