1
0
mirror of https://github.com/golang/go synced 2024-11-25 04:27:56 -07:00

fix for long label names impacting column width of previous lines

R=rsc
http://go/go-review/1013017
This commit is contained in:
Robert Griesemer 2009-10-28 10:14:59 -07:00
parent d2829faa7c
commit 5a02eb65ef
3 changed files with 40 additions and 1 deletions

View File

@ -418,7 +418,12 @@ func (p *printer) writeWhitespace(n int) {
// part of the comment whitespace prefix and the comment
// will be positioned correctly indented.
if i+1 < n && p.buffer[i+1] == unindent {
p.buffer[i], p.buffer[i+1] = unindent, ch;
// Use a formfeed to terminate the current section.
// Otherwise, a long label name on the next line leading
// to a wide column may increase the indentation column
// of lines before the label; effectively leading to wrong
// indentation.
p.buffer[i], p.buffer[i+1] = unindent, formfeed;
i--; // do it again
continue;
}

View File

@ -156,3 +156,20 @@ func _() {
_ = 0;
}
}
func _() {
if {
_ = 0;
}
_ = 0; // the indentation here should not be affected by the long label name
AnOverlongLabel:
_ = 0;
if {
_ = 0;
}
_ = 0;
L: _ = 0;
}

View File

@ -174,3 +174,20 @@ func _() {
_ = 0;
}
}
func _() {
if {
_ = 0;
}
_ = 0; // the indentation here should not be affected by the long label name
AnOverlongLabel:
_ = 0;
if {
_ = 0;
}
_ = 0;
L: _ = 0;
}