branch: elpa/swift-mode commit d053d31595051c9d4feaf0ec1119f259f8a2a8f9 Author: ap4y <l...@pisem.net> Commit: ap4y <l...@pisem.net>
Use greedy regex in interpolation highlighting to prevent issues with expression nested in function calls --- swift-mode.el | 4 +--- test/font-lock-tests.el | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index 24bdff4..a1eccc2 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -355,9 +355,7 @@ (remove-text-properties start end '(swift-interpolation-match-data)) (funcall (syntax-propertize-rules - ((rx (or line-start (not (any "\\"))) - (zero-or-more "\\\\") - (group "\\(" (zero-or-more any) ")")) + ((rx (group "\\(" (*? any) ")")) (0 (ignore (swift-syntax-propertize-interpolation))))) start end))) diff --git a/test/font-lock-tests.el b/test/font-lock-tests.el index 3bdaa4e..d1ddafc 100644 --- a/test/font-lock-tests.el +++ b/test/font-lock-tests.el @@ -187,6 +187,8 @@ test will fail." (check-face class/base-type-colon-has-default-face/1 nil "class T {{:}} Base") (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/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") (check-face super/has-keyword-face/1 font-lock-keyword-face "{{super}}.foo")