From f8403849272e779fcc48cf388fca0aed3b9cd2b2 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Thu, 10 Oct 2019 15:59:58 -0700 Subject: [PATCH] php - fix custom tags appearing invalid Fixes https://github.com/microsoft/vscode/issues/76997 --- extensions/php/build/update-grammar.js | 13 +++- extensions/php/syntaxes/html.tmLanguage.json | 2 +- .../test/colorize-fixtures/issue-76997.php | 1 + .../colorize-results/issue-76997_php.json | 68 +++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 extensions/php/test/colorize-fixtures/issue-76997.php create mode 100644 extensions/php/test/colorize-results/issue-76997_php.json diff --git a/extensions/php/build/update-grammar.js b/extensions/php/build/update-grammar.js index da01c30d40d..9de0d054233 100644 --- a/extensions/php/build/update-grammar.js +++ b/extensions/php/build/update-grammar.js @@ -21,6 +21,14 @@ function adaptInjectionScope(grammar) { injections[newInjectionKey] = injection; } +function includeDerivativeHtml(grammar) { + grammar.patterns.forEach(pattern => { + if (pattern.include === 'text.html.basic') { + pattern.include = 'text.html.derivative'; + } + }); +} + // Workaround for https://github.com/Microsoft/vscode/issues/40279 // and https://github.com/Microsoft/vscode-textmate/issues/59 function fixBadRegex(grammar) { @@ -61,4 +69,7 @@ function fixBadRegex(grammar) { } updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex); -updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope); +updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', grammar => { + adaptInjectionScope(grammar); + includeDerivativeHtml(grammar); +}); diff --git a/extensions/php/syntaxes/html.tmLanguage.json b/extensions/php/syntaxes/html.tmLanguage.json index 09d631c14c2..4bf15294159 100644 --- a/extensions/php/syntaxes/html.tmLanguage.json +++ b/extensions/php/syntaxes/html.tmLanguage.json @@ -129,7 +129,7 @@ "name": "comment.line.shebang.php" }, { - "include": "text.html.basic" + "include": "text.html.derivative" } ], "repository": { diff --git a/extensions/php/test/colorize-fixtures/issue-76997.php b/extensions/php/test/colorize-fixtures/issue-76997.php new file mode 100644 index 00000000000..2aedec98999 --- /dev/null +++ b/extensions/php/test/colorize-fixtures/issue-76997.php @@ -0,0 +1 @@ + diff --git a/extensions/php/test/colorize-results/issue-76997_php.json b/extensions/php/test/colorize-results/issue-76997_php.json new file mode 100644 index 00000000000..c6863dda6fb --- /dev/null +++ b/extensions/php/test/colorize-results/issue-76997_php.json @@ -0,0 +1,68 @@ +[ + { + "c": "<", + "t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html", + "r": { + "dark_plus": "punctuation.definition.tag: #808080", + "light_plus": "punctuation.definition.tag: #800000", + "dark_vs": "punctuation.definition.tag: #808080", + "light_vs": "punctuation.definition.tag: #800000", + "hc_black": "punctuation.definition.tag: #808080" + } + }, + { + "c": "hello", + "t": "text.html.php meta.tag.other.unrecognized.html.derivative entity.name.tag.html", + "r": { + "dark_plus": "entity.name.tag: #569CD6", + "light_plus": "entity.name.tag: #800000", + "dark_vs": "entity.name.tag: #569CD6", + "light_vs": "entity.name.tag: #800000", + "hc_black": "entity.name.tag: #569CD6" + } + }, + { + "c": ">", + "t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html", + "r": { + "dark_plus": "punctuation.definition.tag: #808080", + "light_plus": "punctuation.definition.tag: #800000", + "dark_vs": "punctuation.definition.tag: #808080", + "light_vs": "punctuation.definition.tag: #800000", + "hc_black": "punctuation.definition.tag: #808080" + } + }, + { + "c": "", + "t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html", + "r": { + "dark_plus": "punctuation.definition.tag: #808080", + "light_plus": "punctuation.definition.tag: #800000", + "dark_vs": "punctuation.definition.tag: #808080", + "light_vs": "punctuation.definition.tag: #800000", + "hc_black": "punctuation.definition.tag: #808080" + } + } +] \ No newline at end of file -- GitLab