File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,25 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) error {
9191 }
9292
9393 if fix := issue .Fix (); fix != nil {
94- end := len (fix .Actual )
94+ current := len (fix .Actual )
9595 for _ , s := range fix .Actual {
96- end += len (s )
96+ current += len (s )
97+ }
98+
99+ end := start + token .Pos (current )
100+
101+ header := strings .Join (fix .Expected , "\n " ) + "\n "
102+
103+ // Adds an extra line between the package and the header.
104+ if end == file .Package {
105+ header += "\n "
97106 }
98107
99108 diag .SuggestedFixes = []analysis.SuggestedFix {{
100109 TextEdits : []analysis.TextEdit {{
101110 Pos : start ,
102- End : start + token . Pos ( end ) ,
103- NewText : []byte (strings . Join ( fix . Expected , " \n " ) + " \n " ),
111+ End : end ,
112+ NewText : []byte (header ),
104113 }},
105114 }}
106115 }
You can’t perform that action at this time.
0 commit comments