branch: elpa/lua-mode
commit 9c275cd3cd1b4a14e3079adf223d616bb452e057
Author: immerrr <[email protected]>
Commit: immerrr <[email protected]>
Add regression test for issue #157, fix lua-get-line-faces
---
test/test-font-lock.el | 9 +++++++++
test/utils.el | 24 +++++++++++++-----------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/test/test-font-lock.el b/test/test-font-lock.el
index 5b9cfce..8fbb974 100644
--- a/test/test-font-lock.el
+++ b/test/test-font-lock.el
@@ -100,6 +100,15 @@ foo = bar"
()
())))
+ (it "does not fontify \"for\" inside strings"
+ ;; Issue #157
+ (expect "local xx = [[
+for abc def
+]]"
+ :to-be-fontified-as '(("local" keyword "xx" variable-name "[["
string)
+ ("for abc def" string)
+ ("]]" string))))
+
(it "fontifies \"for x123 =\""
(expect "for x123 ="
:to-be-fontified-as '(("for" keyword "x123" variable-name))))
diff --git a/test/utils.el b/test/utils.el
index 4192db0..6b05737 100644
--- a/test/utils.el
+++ b/test/utils.el
@@ -56,16 +56,17 @@ E.g. for properly fontified Lua string \"local x = 100\" it
should return
\"x\" font-lock-variable-name-face
\"100\" font-lock-constant-face)
"
- (let ((pos 0)
- nextpos
- result prop newprop)
- (while pos
- (setq nextpos (next-property-change pos str)
- newprop (or (get-text-property pos 'face str)
- (get-text-property pos 'font-lock-face str)))
+ (let* ((pos 0)
+ (prop (or (get-text-property pos 'face str)
+ (get-text-property pos 'font-lock-face str)))
+ (nextpos 0)
+ newprop
+ result)
+ (while nextpos
+ (setq nextpos (next-property-change nextpos str))
+ (setq newprop (when nextpos (or (get-text-property nextpos 'face str)
+ (get-text-property nextpos
'font-lock-face str))))
(when (not (equal prop newprop))
- (setq prop newprop)
-
(when (listp prop)
(when (eq (car-safe (last prop)) 'default)
(setq prop (butlast prop)))
@@ -76,8 +77,9 @@ E.g. for properly fontified Lua string \"local x = 100\" it
should return
(setq prop nil))))
(when prop
(push (substring-no-properties str pos nextpos) result)
- (push prop result)))
- (setq pos nextpos))
+ (push prop result))
+ (setq prop newprop
+ pos nextpos)))
(nreverse result)))
(defun lua-fontify-str (str)