Skip to content

Commit b629b4e

Browse files
authored
Merge pull request #1226 from samglt/swift-string-interp
Don't pair escaped parens in swift-mode
2 parents 603325a + e5224c8 commit b629b4e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

smartparens-swift.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
(sp-local-pair "<" ">"
108108
:when '(sp-swift-filter-angle-brackets)
109109
:skip-match 'sp-swift-skip-match-angle-bracket)
110-
(sp-local-pair "\"\"\"" "\"\"\""))
110+
(sp-local-pair "\"\"\"" "\"\"\"")
111+
(sp-local-pair "\\(" ")" :actions '(wrap insert) :when '(sp-in-string-p)))
111112

112113
;; Swift has no sexp suffixes. This fixes slurping
113114
;; (|foo).bar -> (foo.bar)

test/smartparens-swift-test.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,10 @@ func bar(x: UInt64) -> Bool {
123123
(mark-whole-buffer)
124124
(call-interactively 'sp-kill-region)
125125
(should (equal (buffer-string) ""))))
126+
127+
(ert-deftest sp-test-swift-string-interp-paren ()
128+
"String interpolation should not escape closing paren"
129+
(sp-test-with-temp-buffer "print(\"foo is: |\")"
130+
(swift-mode)
131+
(execute-kbd-macro "\\(")
132+
(sp-buffer-equals "print(\"foo is: \\(|)\")")))

0 commit comments

Comments
 (0)