Skip to content

Commit c39ce21

Browse files
committed
internal/lsp: expose option to disable timeouts for completion
This is useful for integration testing. Fixes golang/go#36142 Change-Id: I175510df19f384a0a027267337925ebae15ef827 Reviewed-on: https://go-review.googlesource.com/c/tools/+/211584 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
1 parent 621d4ee commit c39ce21

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/lsp/source/options.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ func (o *Options) set(name string, value interface{}) OptionResult {
250250
result.setBool(&o.Completion.CaseSensitive)
251251
case "completeUnimported":
252252
result.setBool(&o.Completion.Unimported)
253+
case "completionTimeout":
254+
if v, ok := result.asInt(); ok {
255+
o.Completion.Budget = time.Duration(v) * time.Second
256+
}
253257

254258
case "hoverKind":
255259
hoverKind, ok := value.(string)
@@ -347,6 +351,15 @@ func (r *OptionResult) asBool() (bool, bool) {
347351
return b, true
348352
}
349353

354+
func (r *OptionResult) asInt() (int, bool) {
355+
b, ok := r.Value.(int)
356+
if !ok {
357+
r.errorf("Invalid type %T for int option %q", r.Value, r.Name)
358+
return 0, false
359+
}
360+
return b, true
361+
}
362+
350363
func (r *OptionResult) setBool(b *bool) {
351364
if v, ok := r.asBool(); ok {
352365
*b = v

0 commit comments

Comments
 (0)