Commit 236aff31 authored by Russ Cox's avatar Russ Cox

gofmt: fix //line handling

Fixes #2369.

R=gri
CC=golang-dev
https://golang.org/cl/5275048
parent 12ece77c
......@@ -77,6 +77,7 @@ var tests = []struct {
{"testdata/rewrite1.input", "-r=Foo->Bar"},
{"testdata/rewrite2.input", "-r=int->bool"},
{"testdata/stdin*.input", "-stdin"},
{"testdata/comments.input", ""},
}
func TestRewrite(t *testing.T) {
......
package main
func main() {}
// comment here
func f() {}
//line foo.go:1
package main
func main() {}
// comment here
func f() {}
//line foo.go:1
......@@ -151,7 +151,7 @@ func (S *Scanner) interpretLineComment(text []byte) {
filename = filepath.Join(S.dir, filename)
}
// update scanner position
S.file.AddLineInfo(S.lineOffset, filename, line-1) // -1 since comment applies to next line
S.file.AddLineInfo(S.lineOffset+len(text)+1, filename, line) // +len(text)+1 since comment applies to next line
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment