Skip to content

Commit 0bae2e5

Browse files
authored
Merge pull request #11660 from nkcsgexi/code-expand-trailing
2 parents 5f9a50d + 5c9099b commit 0bae2e5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/SourceKit/CodeExpand/code-expand.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,10 @@ func f1() {
8181
// CHECK: bar(a : {}}, <#T##d: () -> ()##() -> ()#>)
8282

8383
foo(withDuration: 1, animations: <#T##() -> Void#>)
84+
85+
if true {
86+
withtrail(<#T##() -> ()#>)
87+
// CHECK: withtrail {
88+
// CHECK-NEXT: <#code#>
89+
}
90+
}

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,8 +1481,13 @@ class PlaceholderExpansionScanner {
14811481
bool walkToStmtPre(Stmt *S) override {
14821482
auto SR = S->getSourceRange();
14831483
if (SR.isValid() && SM.rangeContainsTokenLoc(SR, TargetLoc)) {
1484-
if (!EnclosingCall && !isa<BraceStmt>(S))
1485-
OuterStmt = S;
1484+
if (!EnclosingCall) {
1485+
if (isa<BraceStmt>(S))
1486+
// In case OuterStmt is already set, we should clear it to nullptr.
1487+
OuterStmt = nullptr;
1488+
else
1489+
OuterStmt = S;
1490+
}
14861491
}
14871492
return true;
14881493
}

0 commit comments

Comments
 (0)