1
0
mirror of https://github.com/golang/go synced 2024-09-30 14:28:33 -06:00

internal/lsp: stop cluttering logs with highlight errors

We used to return an error from textDocument/highlight if the cursor
wasn't over an identifier. Logging these errors is not useful, as the
cursor is often not on an identifier.

Change-Id: Ibb43908149315c72923a22bdca567aa2b3ee68d8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/199640
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-10-07 12:55:38 -04:00
parent 83b12cb08e
commit 944452d4f0

View File

@ -39,11 +39,12 @@ func Highlight(ctx context.Context, view View, uri span.URI, pos protocol.Positi
}
path, _ := astutil.PathEnclosingInterval(file, rng.Start, rng.Start)
if len(path) == 0 {
return nil, errors.Errorf("no enclosing position found for %f:%f", pos.Line, pos.Character)
return nil, errors.Errorf("no enclosing position found for %v:%v", int(pos.Line), int(pos.Character))
}
id, ok := path[0].(*ast.Ident)
if !ok {
return nil, errors.Errorf("%f:%f is not an identifier", pos.Line, pos.Character)
// If the cursor is not within an identifier, return empty results.
return []protocol.Range{}, nil
}
var result []protocol.Range
if id.Obj != nil {