internal/lsp: trim progress report messages
Progress reporting has three different kinds, "begin", "report" and
"end". Each of them comes with a text message attached.
The "report" kind is sometimes raw output, for example from go test, so
the output could end with a newline.
This change trims "report" messages to ensure consistency with "begin"
and "end" that doesn't end with a newline.
Change-Id: I779dc41fdf3f6281d9d44f64e9cee9bbcde0b4cd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/266078
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Daniel Martà <mvdan@mvdan.cc>
Trust: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/progress.go b/internal/lsp/progress.go
index 4d18fd8..a8894f8 100644
--- a/internal/lsp/progress.go
+++ b/internal/lsp/progress.go
@@ -8,6 +8,7 @@
"context"
"math/rand"
"strconv"
+ "strings"
"sync"
"golang.org/x/tools/internal/event"
@@ -176,6 +177,7 @@
// to send incremental messages.
return
}
+ message = strings.TrimSuffix(message, "\n")
err := wd.client.Progress(wd.ctx, &protocol.ProgressParams{
Token: wd.token,
Value: &protocol.WorkDoneProgressReport{