diff options
| author | Daniel Martí <mvdan@mvdan.cc> | 2017-08-17 15:51:35 +0100 |
|---|---|---|
| committer | Daniel Martí <mvdan@mvdan.cc> | 2017-08-18 06:59:48 +0000 |
| commit | 59413d34c92cf5ce9b0e70e7105ed73a24849b3e (patch) | |
| tree | 858c93ecabecd2f768046e33ea11b3530b74f78d /src/text | |
| parent | b73d46de36e937819f34a37a46af73eb435246aa (diff) | |
| download | go-59413d34c92cf5ce9b0e70e7105ed73a24849b3e.tar.xz | |
all: unindent some big chunks of code
Found with mvdan.cc/unindent. Prioritized the ones with the biggest wins
for now.
Change-Id: I2b032e45cdd559fc9ed5b1ee4c4de42c4c92e07b
Reviewed-on: https://go-review.googlesource.com/56470
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/text')
| -rw-r--r-- | src/text/tabwriter/tabwriter.go | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/text/tabwriter/tabwriter.go b/src/text/tabwriter/tabwriter.go index 752c9b8e9f..c17cef8bd9 100644 --- a/src/text/tabwriter/tabwriter.go +++ b/src/text/tabwriter/tabwriter.go @@ -333,52 +333,53 @@ func (b *Writer) format(pos0 int, line0, line1 int) (pos int) { for this := line0; this < line1; this++ { line := b.lines[this] - if column < len(line)-1 { - // cell exists in this column => this line - // has more cells than the previous line - // (the last cell per line is ignored because cells are - // tab-terminated; the last cell per line describes the - // text before the newline/formfeed and does not belong - // to a column) + if column >= len(line)-1 { + continue + } + // cell exists in this column => this line + // has more cells than the previous line + // (the last cell per line is ignored because cells are + // tab-terminated; the last cell per line describes the + // text before the newline/formfeed and does not belong + // to a column) - // print unprinted lines until beginning of block - pos = b.writeLines(pos, line0, this) - line0 = this + // print unprinted lines until beginning of block + pos = b.writeLines(pos, line0, this) + line0 = this - // column block begin - width := b.minwidth // minimal column width - discardable := true // true if all cells in this column are empty and "soft" - for ; this < line1; this++ { - line = b.lines[this] - if column < len(line)-1 { - // cell exists in this column - c := line[column] - // update width - if w := c.width + b.padding; w > width { - width = w - } - // update discardable - if c.width > 0 || c.htab { - discardable = false - } - } else { - break + // column block begin + width := b.minwidth // minimal column width + discardable := true // true if all cells in this column are empty and "soft" + for ; this < line1; this++ { + line = b.lines[this] + if column < len(line)-1 { + // cell exists in this column + c := line[column] + // update width + if w := c.width + b.padding; w > width { + width = w } + // update discardable + if c.width > 0 || c.htab { + discardable = false + } + } else { + break } - // column block end - - // discard empty columns if necessary - if discardable && b.flags&DiscardEmptyColumns != 0 { - width = 0 - } + } + // column block end - // format and print all columns to the right of this column - // (we know the widths of this column and all columns to the left) - b.widths = append(b.widths, width) // push width - pos = b.format(pos, line0, this) - b.widths = b.widths[0 : len(b.widths)-1] // pop width - line0 = this + // discard empty columns if necessary + if discardable && b.flags&DiscardEmptyColumns != 0 { + width = 0 } + + // format and print all columns to the right of this column + // (we know the widths of this column and all columns to the left) + b.widths = append(b.widths, width) // push width + pos = b.format(pos, line0, this) + b.widths = b.widths[0 : len(b.widths)-1] // pop width + line0 = this } // print unprinted lines until end |
