Adopt monaco-editor-core that doesn't register html

This commit is contained in:
Alex Dima 2016-09-16 23:19:17 +02:00
parent e1a09ac16d
commit 83bf09fbef
4 changed files with 15 additions and 3 deletions

View file

@ -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",

View file

@ -20,7 +20,7 @@ interface ILangImpl {
let languageDefinitions:{[languageId:string]:ILang} = {};
export function loadLanguage(languageId:string): monaco.Promise<void> {
function _loadLanguage(languageId:string): monaco.Promise<void> {
let module = languageDefinitions[languageId].module;
return new _monaco.Promise<void>((c, e, p) => {
require<ILangImpl>([module], (mod) => {
@ -31,6 +31,15 @@ export function loadLanguage(languageId:string): monaco.Promise<void> {
});
}
let languagePromises:{[languageId:string]: monaco.Promise<void>} = {};
export function loadLanguage(languageId:string): monaco.Promise<void> {
if (!languagePromises[languageId]) {
languagePromises[languageId] = _loadLanguage(languageId);
}
return languagePromises[languageId];
}
function registerLanguage(def:ILang): void {
let languageId = def.id;

View file

@ -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 = <ILanguage> {
defaultToken: '',
tokenPostfix: '',
ignoreCase: true,
// ignoreCase: true,
// The main tokenizer for our languages
tokenizer: {

View file

@ -1840,6 +1840,8 @@ testTokenization(['php', 'css'], [
line: '<!--c--><?',
tokens: [
{ startIndex:0, type: htmlTokenTypes.DELIM_COMMENT },
{ startIndex:4, type: htmlTokenTypes.COMMENT },
{ startIndex:5, type: htmlTokenTypes.DELIM_COMMENT },
{ startIndex:8, type: 'metatag.php' }
]}],