Skip to content

Commit 848d088

Browse files
committed
Fix indentation after attributes with arguments
1 parent 174bccc commit 848d088

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

swift-mode-lexer.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,18 @@
283283
t)
284284

285285
;; Supress implicit semicolon after attributes.
286-
((string-prefix-p "@" (swift-mode:token:text previous-token)) nil)
286+
((string-prefix-p "@" (swift-mode:token:text previous-token))
287+
nil)
288+
289+
;; Supress implicit semicolon after attributes with arguments.
290+
((and
291+
(eq (swift-mode:token:type previous-token) '\))
292+
(save-excursion
293+
(backward-list)
294+
(string-prefix-p
295+
"@"
296+
(swift-mode:token:text (swift-mode:backward-token-simple)))))
297+
nil)
287298

288299
;; Inserts implicit semicolon before keywords that behave like method
289300
;; names.

test/swift-files/declarations.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Foo {
2929
=
3030
xx
3131

32-
@ABC
32+
@ABC(aaa)
3333
final
3434
unowned(safe)
3535
fileprivate
@@ -234,6 +234,15 @@ func
234234
foo()
235235
}
236236

237+
func
238+
foo()
239+
->
240+
@A(aaa)
241+
B {
242+
foo()
243+
foo()
244+
}
245+
237246
// Enumeration declarations
238247

239248
fileprivate

0 commit comments

Comments
 (0)