From 846828e8ce7c48d1d6976becab4773300c61d2ba Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Mon, 16 Dec 2019 17:46:43 -0500 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/source/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/lsp/source/format.go b/internal/lsp/source/format.go index 35b798168b7..3a846bf4179 100644 --- a/internal/lsp/source/format.go +++ b/internal/lsp/source/format.go @@ -132,13 +132,13 @@ func computeImportEdits(ctx context.Context, view View, ph ParseGoHandle, option if err != nil { return nil, nil, err } - origImports, origImportOffset := trimToImports(view.Session().Cache().FileSet(), origAST, origData) allFixes, err := imports.FixImports(filename, origData, options) if err != nil { return nil, nil, err } + origImports, origImportOffset := trimToImports(view.Session().Cache().FileSet(), origAST, origData) allFixEdits, err = computeFixEdits(view, ph, options, origData, origAST, origMapper, origImports, origImportOffset, allFixes) if err != nil { return nil, nil, err