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>
diff --git a/internal/lsp/source/highlight.go b/internal/lsp/source/highlight.go
index 64fa906..8c0c104 100644
--- a/internal/lsp/source/highlight.go
+++ b/internal/lsp/source/highlight.go
@@ -39,11 +39,12 @@
}
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 {