From 83bf09fbef5caa417e0711bc306be774767c4c86 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Fri, 16 Sep 2016 23:19:17 +0200 Subject: [PATCH] Adopt monaco-editor-core that doesn't register html --- package.json | 2 +- src/monaco.contribution.ts | 11 ++++++++++- src/php.ts | 3 ++- test/php.test.ts | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1c18adb0..d77e897d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "jsdom-no-contextify": "^3.1.0", "merge-stream": "^1.0.0", "mocha": "^2.5.3", - "monaco-editor-core": "0.7.0", + "monaco-editor-core": "0.7.0-next.2", "object-assign": "^4.1.0", "rimraf": "^2.5.2", "typescript": "^1.8.10", diff --git a/src/monaco.contribution.ts b/src/monaco.contribution.ts index d6ce8c93..65977618 100644 --- a/src/monaco.contribution.ts +++ b/src/monaco.contribution.ts @@ -20,7 +20,7 @@ interface ILangImpl { let languageDefinitions:{[languageId:string]:ILang} = {}; -export function loadLanguage(languageId:string): monaco.Promise { +function _loadLanguage(languageId:string): monaco.Promise { let module = languageDefinitions[languageId].module; return new _monaco.Promise((c, e, p) => { require([module], (mod) => { @@ -31,6 +31,15 @@ export function loadLanguage(languageId:string): monaco.Promise { }); } +let languagePromises:{[languageId:string]: monaco.Promise} = {}; + +export function loadLanguage(languageId:string): monaco.Promise { + if (!languagePromises[languageId]) { + languagePromises[languageId] = _loadLanguage(languageId); + } + return languagePromises[languageId]; +} + function registerLanguage(def:ILang): void { let languageId = def.id; diff --git a/src/php.ts b/src/php.ts index c2d4b7e8..e22a5b3e 100644 --- a/src/php.ts +++ b/src/php.ts @@ -35,6 +35,7 @@ export const htmlTokenTypes = { DELIM_START: 'start.delimiter.tag.html', DELIM_END: 'end.delimiter.tag.html', DELIM_COMMENT: 'comment.html', + COMMENT: 'comment.content.html', getTag: (name: string) => { return 'tag.html'; } @@ -43,7 +44,7 @@ export const htmlTokenTypes = { export var language = { defaultToken: '', tokenPostfix: '', - ignoreCase: true, + // ignoreCase: true, // The main tokenizer for our languages tokenizer: { diff --git a/test/php.test.ts b/test/php.test.ts index 34671eaa..ef05f473 100644 --- a/test/php.test.ts +++ b/test/php.test.ts @@ -1840,6 +1840,8 @@ testTokenization(['php', 'css'], [ line: '