Skip to content

Commit 7c85d04

Browse files
authored
---
yaml --- r: 319463 b: refs/heads/master-rebranch c: 7a978d8 h: refs/heads/master i: 319461: 135831d 319459: 22f86b8 319455: c6ecd1f
1 parent d9d4e1a commit 7c85d04

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,4 +1457,4 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14571457
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14581458
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14591459
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1460-
refs/heads/master-rebranch: 433f6bf5165a16213e37e95ab79b484f3195d074
1460+
refs/heads/master-rebranch: 7a978d8f5e13928c56818da30446a4b3318e7e0a

branches/master-rebranch/test/SourceKit/CodeFormat/indent-switch.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ func foo3() {
4141
println("It's something else")
4242
}
4343
}
44+
45+
func foo4() {
46+
var test : Int = 1
47+
switch test {
48+
case 0:
49+
print()
50+
case 1:
51+
break
52+
default:
53+
break
54+
}
55+
}
56+
4457
// RUN: %sourcekitd-test -req=format -line=3 -length=1 %s >%t.response
4558
// RUN: %sourcekitd-test -req=format -line=4 -length=1 %s >>%t.response
4659
// RUN: %sourcekitd-test -req=format -line=5 -length=1 %s >>%t.response
@@ -76,6 +89,15 @@ func foo3() {
7689
// RUN: %sourcekitd-test -req=format -line=41 -length=1 %s >>%t.response
7790
// RUN: %sourcekitd-test -req=format -line=42 -length=1 %s >>%t.response
7891

92+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=47 -length=1 %s >>%t.response
93+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=48 -length=1 %s >>%t.response
94+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=49 -length=1 %s >>%t.response
95+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=50 -length=1 %s >>%t.response
96+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=51 -length=1 %s >>%t.response
97+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=52 -length=1 %s >>%t.response
98+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=53 -length=1 %s >>%t.response
99+
// RUN: %sourcekitd-test -req=format -req-opts=indent_switch_case=1 -line=54 -length=1 %s >>%t.response
100+
79101
// RUN: %FileCheck --strict-whitespace %s <%t.response
80102

81103
// CHECK: key.sourcetext: " switch (test) {"
@@ -112,3 +134,12 @@ func foo3() {
112134
// CHECK: key.sourcetext: " default:"
113135
// CHECK: key.sourcetext: " println(\"It's something else\")"
114136
// CHECK: key.sourcetext: " }"
137+
138+
// CHECK: key.sourcetext: " switch test {"
139+
// CHECK: key.sourcetext: " case 0:"
140+
// CHECK: key.sourcetext: " print()"
141+
// CHECK: key.sourcetext: " case 1:"
142+
// CHECK: key.sourcetext: " break"
143+
// CHECK: key.sourcetext: " default:"
144+
// CHECK: key.sourcetext: " break"
145+
// CHECK: key.sourcetext: " }"

branches/master-rebranch/tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,10 +1904,12 @@ void SwiftEditorDocument::applyFormatOptions(OptionsDictionary &FmtOptions) {
19041904
static UIdent KeyUseTabs("key.editor.format.usetabs");
19051905
static UIdent KeyIndentWidth("key.editor.format.indentwidth");
19061906
static UIdent KeyTabWidth("key.editor.format.tabwidth");
1907+
static UIdent KeyIndentSwitchCase("key.editor.format.indent_switch_case");
19071908

19081909
FmtOptions.valueForOption(KeyUseTabs, Impl.FormatOptions.UseTabs);
19091910
FmtOptions.valueForOption(KeyIndentWidth, Impl.FormatOptions.IndentWidth);
19101911
FmtOptions.valueForOption(KeyTabWidth, Impl.FormatOptions.TabWidth);
1912+
FmtOptions.valueForOption(KeyIndentSwitchCase, Impl.FormatOptions.IndentSwitchCase);
19111913
}
19121914

19131915
const CodeFormatOptions &SwiftEditorDocument::getFormatOptions() {

0 commit comments

Comments
 (0)