Skip to content

Commit 6ee1a4e

Browse files
committed
Allow expansion of trailing placeholders that only have a type and no text
1 parent 1ba8552 commit 6ee1a4e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Sources/SwiftRefactor/ExpandEditorPlaceholder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ fileprivate enum EditorPlaceholderData {
309309
var typeText: Substring
310310
(text, typeText) = split(text, separatedBy: "##")
311311
if typeText.isEmpty {
312-
// No type information
313-
self = .basic(text: text)
312+
// Only type information present
313+
self.init(typeText: text)
314314
return
315315
}
316316

Tests/SwiftRefactorTest/ExpandEditorPlaceholdersTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,20 @@ final class ExpandEditorPlaceholdersTest: XCTestCase {
5252
try assertRefactorPlaceholderCall(baseline, expected: expected)
5353
}
5454

55+
func testPlaceholderWithoutExplicitText() throws {
56+
let placeholder = ExpandEditorPlaceholder.wrapInPlaceholder("T##(Int) -> Void")
57+
let baseline = "call(\(placeholder))"
58+
59+
let int = ExpandEditorPlaceholder.wrapInPlaceholder("Int")
60+
let expected: String = """
61+
call { \(int) in
62+
\(voidPlaceholder)
63+
}
64+
"""
65+
66+
try assertRefactorPlaceholderCall(baseline, expected: expected)
67+
}
68+
5569
func testMultipleClosureArgs() throws {
5670
let baseline = "call(arg1: \(closurePlaceholder), arg2: \(closurePlaceholder))"
5771

0 commit comments

Comments
 (0)