on master help sign in
Avoid extra indentation on Go switches (#6817)
e7f25d8Daniel Martí
runtime/queries/go/indents.scm+16−4
@@ -14,8 +14,6 @@
14 (argument_list)
14 (argument_list)
15 (field_declaration_list)
15 (field_declaration_list)
16 (block)
16 (block)
17− (type_switch_statement)
18− (expression_switch_statement)
19 (var_declaration)
17 (var_declaration)
20] @indent
18] @indent
21
19
@@ -24,5 +22,19 @@
24 ")"
22 ")"
25] @outdent
23] @outdent
26
24
25+; Switches and selects aren't indented, only their case bodies are.
26+; Outdent all closing braces except those closing switches or selects.
27+(
28+ (_ "}" @outdent) @outer
27−((_ "}" @outdent) @outer (#not-kind-eq? @outer "select_statement"))
29+ (#not-kind-eq? @outer "select_statement")
30+ (#not-kind-eq? @outer "type_switch_statement")
31+ (#not-kind-eq? @outer "expression_switch_statement")
32+)
33+
34+; Starting a line after a new case should indent.
35+[
28−(communication_case) @extend
36+ (communication_case)
37+ (expression_case)
38+ (default_case)
39+ (type_case)
40+] @extend