• Dmitri Shuralyov's avatar
    go/printer: set prefix correctly when all comment lines blank · 928c83ff
    Dmitri Shuralyov authored
    In stripCommonPrefix, the prefix was correctly calculated in all cases,
    except one. That unhandled case is when there are more than 2 lines,
    but all lines are blank (other than the first and last lines,
    which contain /* and */ respectively).
    This change detects that case and correctly sets the prefix calculated
    from the last line. This is consistent with the (correct) behavior
    that happens when there's at least one non-blank line.
    That fixes issue #9751 that occurs for problematic input,
    where cmd/gofmt and go/source would insert extra indentation on
    every format operation. It also allows go/printer itself to print
    such parsed files in an expected way.
    
    Fixes #9751.
    
    Change-Id: Id3dfb945beb59ffad3705085a3c285fca30a5f87
    Reviewed-on: https://go-review.googlesource.com/3684Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    928c83ff
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...