Skip to content

Commit 3f29cf0

Browse files
author
Nathan Hawes
committed
[SourceKit/CodeFormat] Update hasOutdent check to handle specialization ranges < >
They were missed before, so < > that should trigger outdenting weren't. E.g. let x = foo< Int, String, Int >() .count // Indented becase we didn't process the < > brackets previously.
1 parent 6b52dca commit 3f29cf0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/IDE/Formatting.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ class RangeWalker: protected ASTWalker {
614614
PL->getStartLoc()))
615615
return Stop;
616616
}
617+
} else if (auto *USE = dyn_cast<UnresolvedSpecializeExpr>(E)) {
618+
SourceLoc ContextLoc = getContextLocForArgs(SM, E);
619+
if (!handleAngles(USE->getLAngleLoc(), USE->getRAngleLoc(), ContextLoc))
620+
return Stop;
617621
} else if (isa<CallExpr>(E) || isa<SubscriptExpr>(E)) {
618622
SourceLoc ContextLoc = getContextLocForArgs(SM, E);
619623
Expr *Arg;

test/swift-indent/basic.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,14 @@ let x = foo<Int,
905905
String,
906906
Int>()
907907

908+
let x = foo<
909+
Int,
910+
String,
911+
Int
912+
>()
913+
.filter { $0 > 10 }
914+
.count
915+
908916

909917
// Invalid elements should still be indented.
910918
//

0 commit comments

Comments
 (0)