branch: elpa/smartparens
commit b629b4e893ba21ba5a381f6c0054bb72f8e96df2
Merge: 603325ab3d e5224c83f4
Author: Matus Goljer <matus.gol...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #1226 from samglt/swift-string-interp
    
    Don't pair escaped parens in swift-mode
---
 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 fc0166b77d..d7831def66 100644
--- a/smartparens-swift.el
+++ b/smartparens-swift.el
@@ -107,7 +107,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 "\\(" ")" :actions '(wrap insert) :when '(sp-in-string-p)))
 
 ;; Swift has no sexp suffixes.  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