diff options
Diffstat (limited to 'vendor/golang.org/x/tools/go')
-rw-r--r-- | vendor/golang.org/x/tools/go/ast/astutil/imports.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/vendor/golang.org/x/tools/go/ast/astutil/imports.go b/vendor/golang.org/x/tools/go/ast/astutil/imports.go index 2e81f4d3a..36c536b5e 100644 --- a/vendor/golang.org/x/tools/go/ast/astutil/imports.go +++ b/vendor/golang.org/x/tools/go/ast/astutil/imports.go @@ -234,16 +234,17 @@ func DeleteNamedImport(fset *token.FileSet, f *ast.File, name, path string) (del } } - gen.Lparen = token.NoPos // drop parens spec := gen.Specs[0].(*ast.ImportSpec) + + // Move the documentation right after the import decl. if spec.Doc != nil { - // Move the documentation above the import statement. - gen.TokPos = spec.Doc.End() + 1 + for fset.Position(gen.TokPos).Line+1 < fset.Position(spec.Doc.Pos()).Line { + fset.File(gen.TokPos).MergeLine(fset.Position(gen.TokPos).Line) + } } - for _, cg := range f.Comments { if cg.End() < spec.Pos() && fset.Position(cg.End()).Line == fset.Position(spec.Pos()).Line { - for fset.Position(gen.TokPos).Line != fset.Position(spec.Pos()).Line { + for fset.Position(gen.TokPos).Line+1 < fset.Position(spec.Pos()).Line { fset.File(gen.TokPos).MergeLine(fset.Position(gen.TokPos).Line) } break |