• Didier Spezia's avatar
    go/format: fix //line corner case when formatting statements · c68f2f89
    Didier Spezia authored
    The code formatting mechanism can be applied to partial Go code,
    such as a list of statements. The statements are wrapped into a
    function definition (to be parsed fine), and unwrapped after formatting.
    
    When the statements contain //line annotations, it may fail,
    because not all comments are flushed by the printer before the final '}'.
    Formatting "\ta()\n//line :1" results in "\ta() }\n\n//line", which
    is wrong.
    
    Tweaked the wrapping/unwrapping code to make sure comments are flushed
    before the '}'.
    
    Fixes #11276
    
    Change-Id: Id15c80279b0382ee9ed939cca1647f525c4929f5
    Reviewed-on: https://go-review.googlesource.com/11282
    Run-TryBot: Robert Griesemer <gri@golang.org>
    Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
    c68f2f89
Name
Last commit
Last update
api Loading commit data...
doc 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...