Skip to content

Commit 846828e

Browse files
committed
internal/lsp/source: fix crash on conflict markers in imports
Generally speaking, if the imports package can operate on a file, we can assume that it's in good enough shape for the rest of our work. That means it's important we run imports first. On one code path, we weren't. Fixes golang/go#36162. Change-Id: I750aff31e0c3706aeb798ceb60c35ea17ba95943 Reviewed-on: https://go-review.googlesource.com/c/tools/+/211580 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
1 parent 1d943b0 commit 846828e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/lsp/source/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ func computeImportEdits(ctx context.Context, view View, ph ParseGoHandle, option
132132
if err != nil {
133133
return nil, nil, err
134134
}
135-
origImports, origImportOffset := trimToImports(view.Session().Cache().FileSet(), origAST, origData)
136135

137136
allFixes, err := imports.FixImports(filename, origData, options)
138137
if err != nil {
139138
return nil, nil, err
140139
}
141140

141+
origImports, origImportOffset := trimToImports(view.Session().Cache().FileSet(), origAST, origData)
142142
allFixEdits, err = computeFixEdits(view, ph, options, origData, origAST, origMapper, origImports, origImportOffset, allFixes)
143143
if err != nil {
144144
return nil, nil, err

0 commit comments

Comments
 (0)