From 5c352bb417e0fe56c8e79873b96ee51f09f5307c Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Thu, 23 Jan 2020 17:05:44 -0500 Subject: [PATCH] internal/lsp: stop returning errors when we can't find a snapshot Change-Id: I319021a3339971809b6096b3271aa6b0d94ae336 Reviewed-on: https://go-review.googlesource.com/c/tools/+/216139 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Heschi Kreinick --- internal/lsp/text_synchronization.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/lsp/text_synchronization.go b/internal/lsp/text_synchronization.go index e5505d9ebd..3a96cebef8 100644 --- a/internal/lsp/text_synchronization.go +++ b/internal/lsp/text_synchronization.go @@ -132,8 +132,11 @@ func (s *Server) didModifyFiles(ctx context.Context, modifications []source.File snapshot = s } } + // If the file isn't in any known views (for example, if it's in a dependency), + // we may not have a snapshot to map it to. As a result, we won't try to + // diagnose it. TODO(rstambler): Figure out how to handle this better. if snapshot == nil { - return nil, errors.Errorf("no snapshot for %s", uri) + continue } snapshotByURI[uri] = snapshot snapshotSet[snapshot] = append(snapshotSet[snapshot], uri)