branch: elpa/swift-mode
commit 27b93dd6ebf83b3fec6ca39aa7aa92faf9051b28
Merge: 7826550 1a1d81c
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Merge pull request #34 from ap4y/string_interpolation_improvements
Improve font-lock regex for string interpolation
---
swift-mode.el | 2 +-
test/font-lock-tests.el | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/swift-mode.el b/swift-mode.el
index 84d00be..dd93a34 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -405,7 +405,7 @@
(remove-text-properties start end '(swift-interpolation-match-data))
(funcall
(syntax-propertize-rules
- ((rx (group "\\(" (*? any) ")"))
+ ((rx (group "\\(" (* (any alnum " " "(" ")" "+" "-" "*" "/")) ")"))
(0 (ignore (swift-syntax-propertize-interpolation)))))
start end)))
diff --git a/test/font-lock-tests.el b/test/font-lock-tests.el
index ed760d4..d4daffc 100644
--- a/test/font-lock-tests.el
+++ b/test/font-lock-tests.el
@@ -188,6 +188,8 @@ test will fail."
(check-face string-interpolation/has-variable-face/1
font-lock-variable-name-face "\"foo {{\\\(bar)}}\"")
(check-face string-interpolation/has-variable-face/2
font-lock-variable-name-face "\"{{\\\(bar)}}\"")
+(check-face string-interpolation/has-variable-face/3
font-lock-variable-name-face "\"\\\(bar\(1\){{\)}}\"")
+(check-face string-interpolation/has-variable-face/4
font-lock-variable-name-face "\"\\\(bar\(1\){{ + baz\(2\)\)}}\"")
(check-face string-interpolation/after-has-string-face/2 font-lock-string-face
"\"(foo \\\(bar){{baz}}\")")
(check-face self/has-keyword-face/1 font-lock-keyword-face "{{self}}.foo")