Skip to content

Commit c9fc190

Browse files
committed
Merge pull request #306 from ejmr/issue-305
Fix invalid highlighting variables which contains 'this' or 'that'
2 parents 9083f3a + d4f4bdf commit c9fc190

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

php-mode-test.el

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,15 @@ style from Drupal."
596596
(should (eq (get-text-property (1- (match-end 0)) 'face)
597597
'php-annotations-annotation-face))))
598598

599+
(ert-deftest php-mode-test-issue-305 ()
600+
"Test highlighting variables which contains 'this' or 'that'."
601+
(with-php-mode-test ("issue-305.php")
602+
(search-forward "Start:")
603+
(search-forward "$this")
604+
(should-not (eq 'font-lock-constant-face (get-text-property (- (point) 1) 'face)))
605+
(search-forward "$that")
606+
(should-not (eq 'font-lock-constant-face (get-text-property (- (point) 1) 'face)))))
607+
599608
;;; php-mode-test.el ends here
600609

601610
;; Local Variables:

php-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ a completion list."
13281328
("->\\(\\sw+\\)\\s-*(" 1 'default)
13291329

13301330
;; Highlight special variables
1331-
("\\$\\(this\\|that\\)" 1 font-lock-constant-face)
1331+
("\\$\\(this\\|that\\)\\_>" 1 font-lock-constant-face)
13321332
("\\(\\$\\|->\\)\\([a-zA-Z0-9_]+\\)" 2 font-lock-variable-name-face)
13331333

13341334
;; Highlight function/method names

tests/issue-305.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
/**
4+
* GitHub Issue: https://github.com/ejmr/php-mode/issues/305
5+
*
6+
* Test highighting of $this_foo, $that_foo
7+
*/
8+
9+
// Start:
10+
$this_foo;
11+
$that_foo;

0 commit comments

Comments
 (0)