branch: elpa/smartparens
commit ac56bd336585e64d23724bd88eb5fcf0f55bbd9b
Author: unset <unset>
Commit: unset <unset>

    Don't pair escaped parens in Swift
---
 smartparens-swift.el           | 3 ++-
 test/smartparens-swift-test.el | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/smartparens-swift.el b/smartparens-swift.el
index a1efab109d..83b012912a 100644
--- a/smartparens-swift.el
+++ b/smartparens-swift.el
@@ -106,7 +106,8 @@
   (sp-local-pair "<" ">"
                  :when '(sp-swift-filter-angle-brackets)
                  :skip-match 'sp-swift-skip-match-angle-bracket)
-  (sp-local-pair "\"\"\"" "\"\"\""))
+  (sp-local-pair "\"\"\"" "\"\"\"")
+  (sp-local-pair "\\(" nil :actions nil))
 
 ;; Swift has no sexp suffices.  This fixes slurping
 ;; (|foo).bar -> (foo.bar)
diff --git a/test/smartparens-swift-test.el b/test/smartparens-swift-test.el
index 4dd7bc1ba6..745cf5fbf3 100644
--- a/test/smartparens-swift-test.el
+++ b/test/smartparens-swift-test.el
@@ -123,3 +123,10 @@ func bar(x: UInt64) -> Bool {
     (mark-whole-buffer)
     (call-interactively 'sp-kill-region)
     (should (equal (buffer-string) ""))))
+
+(ert-deftest sp-test-swift-string-interp-paren ()
+  "String interpolation should not escape closing paren"
+  (sp-test-with-temp-buffer "print(\"foo is: |\")"
+      (swift-mode)
+    (execute-kbd-macro "\\(")
+    (sp-buffer-equals "print(\"foo is: \\(|)\")")))

Reply via email to