From 944452d4f0736c69c81c56d81e67676d393bb119 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Mon, 7 Oct 2019 12:55:38 -0400 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/source/highlight.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/lsp/source/highlight.go b/internal/lsp/source/highlight.go index 64fa906e74..8c0c1041e8 100644 --- a/internal/lsp/source/highlight.go +++ b/internal/lsp/source/highlight.go @@ -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 {