Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue/format: expose indent option
Browse files Browse the repository at this point in the history
Change-Id: Ib66be75914726c62982af78d7f3c32ff3cdf1594
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9481
Reviewed-by: Marcel van Lohuizen <[email protected]>
  • Loading branch information
mpvl committed Apr 23, 2021
1 parent b8ce660 commit f044ad1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cue/format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func TabIndent(indent bool) Option {
return func(c *config) { c.TabIndent = indent }
}

// IndentPrefix specifies the number of tabstops to use as a prefix for every
// line.
func IndentPrefix(n int) Option {
return func(c *config) { c.Indent = n }
}

// TODO: make public
// sortImportsOption causes import declarations to be sorted.
func sortImportsOption() Option {
Expand Down
2 changes: 1 addition & 1 deletion cue/format/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (p *printer) Print(v interface{}) {
// 2) simplified structs are explicitly referenced separately
// in the AST.
if p.indent < 6 {
data = literal.IndentTabs(data, p.indent+1)
data = literal.IndentTabs(data, p.cfg.Indent+p.indent+1)
}

case token.INT:
Expand Down

0 comments on commit f044ad1

Please sign in to comment.