Skip to content

Commit ae4564c

Browse files
committed
fix: correct highlight of php heredoc strings with one word on line
1 parent a194253 commit ae4564c

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

lib/ace/mode/_test/text_php.txt

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<?php
2+
$bar = <<<EOD
3+
highlightingWithNoSpaces
4+
doesn't break
5+
EOD;
6+
7+
lorem('ipsum', <<<TEST
8+
foo bar
9+
TEST
10+
);
211

312
function nfact($n) {
413
if ($n == 0) {

lib/ace/mode/_test/tokens_php.json

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,43 @@
11
[[
22
"php-start",
33
["support.php_tag","<?php"]
4+
],[
5+
["php-heredoc","EOD"],
6+
["variable","$bar"],
7+
["text"," "],
8+
["keyword.operator","="],
9+
["text"," "],
10+
["markup.list","<<<EOD"]
11+
],[
12+
["php-heredoc","EOD"],
13+
["string","highlightingWithNoSpaces"]
14+
],[
15+
["php-heredoc","EOD"],
16+
["string","doesn't break"]
17+
],[
18+
"php-start",
19+
["markup.list","EOD"],
20+
["punctuation.operator",";"]
21+
],[
22+
"php-start"
23+
],[
24+
["php-heredoc","TEST"],
25+
["identifier","lorem"],
26+
["paren.lparen","("],
27+
["string","'ipsum'"],
28+
["punctuation.operator",","],
29+
["text"," "],
30+
["markup.list","<<<TEST"]
31+
],[
32+
["php-heredoc","TEST"],
33+
["string","foo bar"]
34+
],[
35+
"php-start",
36+
["markup.list","TEST"]
37+
],[
38+
"php-start",
39+
["paren.rparen",")"],
40+
["punctuation.operator",";"]
441
],[
542
"php-start"
643
],[
@@ -169,4 +206,4 @@
169206
["constant.language.escape.reference.xml","&js;"]
170207
],[
171208
"start"
172-
]]
209+
]]

lib/ace/mode/php_highlight_rules.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1018,15 +1018,18 @@ sql_regcase'.split('|')
10181018
],
10191019
"heredoc" : [
10201020
{
1021-
onMatch : function(value, currentSate, stack) {
1022-
if (stack[1] != value)
1021+
onMatch : function(value, currentState, stack) {
1022+
if (stack[1] != value) {
1023+
this.next = "";
10231024
return "string";
1025+
}
10241026
stack.shift();
10251027
stack.shift();
1028+
this.next = this.nextState;
10261029
return "markup.list";
10271030
},
10281031
regex : "^\\w+(?=;?$)",
1029-
next: "start"
1032+
nextState: "start"
10301033
}, {
10311034
token: "string",
10321035
regex : ".*"

0 commit comments

Comments
 (0)