From 47ea21585cd7cbaa6078713a14b5f9a116791382 Mon Sep 17 00:00:00 2001 From: Muir Manders Date: Wed, 26 Jun 2019 23:28:06 +0000 Subject: [PATCH] internal/lsp: propagate context.Canceled when type checking typeCheck() was swallowing context.Canceled errors and leaving the cached package in a bad state. In particular, after two rapid changes to imports I was left in the "no package for file" error mode until I change my imports again. The second change canceled the first change which ended up sticking a skeleton *pkg in the package cache instead of propagating the canceled error. Change-Id: I15b072188c3359d9cd1812bd49e72548ba214250 GitHub-Last-Rev: 240f61718fbb5bfc787bbfaaaae1d38925d7c405 GitHub-Pull-Request: golang/tools#126 Reviewed-on: https://go-review.googlesource.com/c/tools/+/183940 Reviewed-by: Rebecca Stambler Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/cache/check.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/lsp/cache/check.go b/internal/lsp/cache/check.go index fab03645d9..d0ee9753f9 100644 --- a/internal/lsp/cache/check.go +++ b/internal/lsp/cache/check.go @@ -142,10 +142,12 @@ func (imp *importer) typeCheck(id packageID) (*pkg, error) { wg.Wait() for _, f := range files { - if f != nil { - pkg.files = append(pkg.files, f) - } + pkg.files = append(pkg.files, f) + if f.err != nil { + if f.err == context.Canceled { + return nil, f.err + } imp.view.session.cache.appendPkgError(pkg, f.err) } }