-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collapse case clauses if they fit in a short line
For now, a short line is one which can be printed in under sixty bytes, including any inline comment. We don't take indentation into account, which will be problematic. For that reason, keep the limit small. We'll fix that in a better way in a later commit. Fixes #3.
- Loading branch information
Showing
2 changed files
with
133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
gofumpt -w foo.go . | ||
cmp foo.go foo.go.golden | ||
|
||
-- foo.go -- | ||
package p | ||
|
||
func f(r rune) { | ||
switch r { | ||
case 'a', | ||
'b', | ||
'c': | ||
|
||
case 'd', 'e', 'f': | ||
|
||
case 'a', 'b', | ||
'c': | ||
|
||
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g', | ||
'l', 'i', 's', 't', '.', '.', '.': | ||
|
||
// before | ||
case 'a', | ||
'b': // inline | ||
// after | ||
|
||
case 'a', // middle | ||
'b': | ||
|
||
case 'a', 'b', 'c', 'd', 'e', 'f', | ||
'g': // very very long inline comment at the end | ||
|
||
case 'a', 'b', 'c', | ||
'd': // short comment | ||
} | ||
} | ||
-- foo.go.golden -- | ||
package p | ||
|
||
func f(r rune) { | ||
switch r { | ||
case 'a', 'b', 'c': | ||
|
||
case 'd', 'e', 'f': | ||
|
||
case 'a', 'b', 'c': | ||
|
||
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g', | ||
'l', 'i', 's', 't', '.', '.', '.': | ||
|
||
// before | ||
case 'a', 'b': // inline | ||
// after | ||
|
||
case 'a', // middle | ||
'b': | ||
|
||
case 'a', 'b', 'c', 'd', 'e', 'f', | ||
'g': // very very long inline comment at the end | ||
|
||
case 'a', 'b', 'c', 'd': // short comment | ||
} | ||
} |