Skip to content

Commit 509d693

Browse files
committed
Fix microsoft#65649 - fix injection patching in update-grammar.js
1 parent b2ac8d2 commit 509d693

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

extensions/php/build/update-grammar.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
var updateGrammar = require('../../../build/npm/update-grammar');
7+
const updateGrammar = require('../../../build/npm/update-grammar');
88

99
function adaptInjectionScope(grammar) {
1010
// we're using the HTML grammar from https://github.com/textmate/html.tmbundle which has moved away from source.js.embedded.html
11-
let oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:text.html.php meta.tag, L:source.js.embedded.html";
12-
let newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:text.html.php meta.tag, L:text.html.php source.js";
11+
const oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))";
12+
const newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php))";
1313

14-
var injections = grammar.injections;
15-
var injection = injections[oldInjectionKey];
16-
if (!injections) {
17-
throw new Error("Can not find PHP injection");
14+
const injections = grammar.injections;
15+
const injection = injections[oldInjectionKey];
16+
if (!injection) {
17+
throw new Error("Can not find PHP injection to patch");
1818
}
1919
delete injections[oldInjectionKey];
2020
injections[newInjectionKey] = injection;
@@ -37,4 +37,3 @@ function fixBadRegex(grammar) {
3737

3838
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
3939
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope);
40-

extensions/php/syntaxes/html.tmLanguage.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
"name": "PHP",
99
"scopeName": "text.html.php",
1010
"injections": {
11-
"text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))": {
12-
"patterns": [
13-
{
14-
"include": "#php-tag"
15-
}
16-
]
17-
},
1811
"L:source.php string.quoted.single.sql.php source.sql.embedded.php": {
1912
"patterns": [
2013
{
@@ -115,6 +108,13 @@
115108
"include": "source.php#interpolation_double_quoted"
116109
}
117110
]
111+
},
112+
"text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php))": {
113+
"patterns": [
114+
{
115+
"include": "#php-tag"
116+
}
117+
]
118118
}
119119
},
120120
"patterns": [

0 commit comments

Comments
 (0)