this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue/format: change default tab width from 8 to 4

We carried over Go's default tab width of 8,
but Marcel clarified earlier this week that he always intended
CUE to use a default tab width of 4.

As further proof that this is what most people expect anyway,
the majority of editors and syntax renderers configure both Go and CUE
with a tab width of 4, not 8, because 8 is too wide for most people.

This only affects tabwriter column alignment of fields and comments
when the lines have different amounts of tab indentation,
which should never happen as we don't align syntax
across different levels of indentation.

Fixes #4290.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I4726a99c83826c6ab2bf0774845a0bbf065919ab
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1233618
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+5 -5
+3 -3
cue/format/format.go
··· 49 49 // UseSpaces specifies that tabs should be converted to spaces and sets the 50 50 // default tab width. 51 51 // 52 - // This option is set to 8 by default. 52 + // This option is set to 4 by default. 53 53 func UseSpaces(tabwidth int) Option { 54 54 return func(c *config) { 55 55 c.useSpaces = true ··· 125 125 type config struct { 126 126 useSpaces bool // default: true 127 127 tabIndent bool // default: true 128 - tabWidth int // default: 8 128 + tabWidth int // default: 4 129 129 indent int // default: 0 (all code is indented at least by this much) 130 130 131 131 simplify bool // default: false ··· 134 134 135 135 func newConfig(opt []Option) *config { 136 136 cfg := &config{ 137 - tabWidth: 8, 137 + tabWidth: 4, 138 138 tabIndent: true, 139 139 useSpaces: true, 140 140 }
+2 -2
cue/format/format_test.go
··· 397 397 want: "foo: {\n\ta: 1\n\tlongField: 2\n}\n", 398 398 }, 399 399 // TabIndent(false) makes the indentation use a tabWidth number of spaces. 400 - // Note that this exposes the default tabWidth value of 8. 400 + // Note that this exposes the default tabWidth value of 4. 401 401 { 402 402 name: "TabIndent=false", 403 403 options: []format.Option{format.TabIndent(false)}, 404 - want: "\"foo\": {\n a: 1\n longField: 2\n}\n", 404 + want: "\"foo\": {\n a: 1\n longField: 2\n}\n", 405 405 }, 406 406 // TabIndent(false) with a custom number of spaces. 407 407 {