Skip to content

Commit bcecb1f

Browse files
committed
internal/lsp: return context cancellation from LookupBuiltin
Change-Id: If90d111fbe89d2be445b15ec3721d48280540de9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/216305 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent 73c4c87 commit bcecb1f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

internal/lsp/cache/view.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ func (v *view) LookupBuiltin(ctx context.Context, name string) (*ast.Object, err
204204
return nil, err
205205
}
206206
data := v.builtin.handle.Get(ctx)
207+
if ctx.Err() != nil {
208+
return nil, ctx.Err()
209+
}
207210
if data == nil {
208211
return nil, errors.Errorf("unexpected nil builtin package")
209212
}

internal/lsp/source/completion_format.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ func (c *completer) formatBuiltin(cand candidate) CompletionItem {
246246
item.Kind = protocol.FunctionCompletion
247247
astObj, err := c.snapshot.View().LookupBuiltin(c.ctx, obj.Name())
248248
if err != nil {
249-
log.Error(c.ctx, "no builtin package", err)
249+
if c.ctx.Err() == nil {
250+
log.Error(c.ctx, "no builtin package", err)
251+
}
250252
break
251253
}
252254
decl, ok := astObj.Decl.(*ast.FuncDecl)

0 commit comments

Comments
 (0)