File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
test/SourceKit/CodeFormat Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -843,6 +843,9 @@ class CodeFormatter {
843
843
auto AddIndentFunc = [&] () {
844
844
auto Width = FmtOptions.UseTabs ? FmtOptions.TabWidth
845
845
: FmtOptions.IndentWidth ;
846
+ // We don't need to add additional indentation if Width is zero.
847
+ if (!Width)
848
+ return ;
846
849
// Increment indent.
847
850
ExpandedIndent += Width;
848
851
// Normalize indent to align on proper column indent width.
Original file line number Diff line number Diff line change
1
+ class Foo {
2
+
3
+ var test : Int
4
+
5
+ func foo( ) {
6
+ test = 1
7
+ }
8
+
9
+ }
10
+ func bar( a: Int ,
11
+ b: Int ) { }
12
+
13
+ // RUN: %sourcekitd-test -req=format -line=1 -length=1 -req-opts=usetabs=0 -req-opts=indentwidth=0 %s >%t.response
14
+ // RUN: %sourcekitd-test -req=format -line=3 -length=1 -req-opts=usetabs=0 -req-opts=indentwidth=0 %s >>%t.response
15
+ // RUN: %sourcekitd-test -req=format -line=6 -length=1 -req-opts=usetabs=0 -req-opts=indentwidth=0 %s >>%t.response
16
+ // RUN: %sourcekitd-test -req=format -line=11 -length=1 -req-opts=usetabs=0 -req-opts=indentwidth=0 %s >>%t.response
17
+ // RUN: %FileCheck --strict-whitespace %s <%t.response
18
+
19
+ // CHECK: key.sourcetext: "class Foo {"
20
+ // CHECK: key.sourcetext: "var test : Int"
21
+ // CHECK: key.sourcetext: " test = 1"
22
+ // CHECK: key.sourcetext: " b: Int) {}"
You can’t perform that action at this time.
0 commit comments