Skip to content

Commit 0e232fa

Browse files
110ystamblerre
authored andcommitted
gopls: add scheme to CodeDescription.href
### gopls - Add `https` scheme to `CodeDescription.href` According to the [LSP specification](https://microsoft.github.io/language-server-protocol/specification#diagnostic), `CodeDescription.href` must be [URI type](https://microsoft.github.io/language-server-protocol/specification#uri). As described in the [RFC](https://tools.ietf.org/html/rfc3986#section-3), the scheme is required for URI: > The scheme and path components are required, though the path may be empty (no characters). Current `gopls` does not add the scheme to `CodeDescription.href`, and this results in some LSP clients ([at least this client](https://github.com/autozimu/LanguageClient-neovim)) which are strictly validating the URI format to be failed to populate diagnostics. Change-Id: I73f01c2e97ed1adb62fbed451a7c9b0c9794b66a GitHub-Last-Rev: 6985bfe GitHub-Pull-Request: #277 Reviewed-on: https://go-review.googlesource.com/c/tools/+/294569 Reviewed-by: Rebecca Stambler <[email protected]> Trust: Rebecca Stambler <[email protected]> Trust: Robert Findley <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 2363391 commit 0e232fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/lsp/cache/errors.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"strconv"
1515
"strings"
1616

17+
errors "golang.org/x/xerrors"
18+
1719
"golang.org/x/tools/go/analysis"
1820
"golang.org/x/tools/go/packages"
1921
"golang.org/x/tools/internal/analysisinternal"
@@ -23,7 +25,6 @@ import (
2325
"golang.org/x/tools/internal/lsp/source"
2426
"golang.org/x/tools/internal/span"
2527
"golang.org/x/tools/internal/typesinternal"
26-
errors "golang.org/x/xerrors"
2728
)
2829

2930
func sourceDiagnostics(ctx context.Context, snapshot *snapshot, pkg *pkg, severity protocol.DiagnosticSeverity, e interface{}) ([]*source.Diagnostic, error) {
@@ -167,7 +168,7 @@ func sourceDiagnostics(ctx context.Context, snapshot *snapshot, pkg *pkg, severi
167168

168169
func typesCodeHref(snapshot *snapshot, code typesinternal.ErrorCode) string {
169170
target := snapshot.View().Options().LinkTarget
170-
return fmt.Sprintf("%s/golang.org/x/tools/internal/typesinternal#%s", target, code.String())
171+
return fmt.Sprintf("https://%s/golang.org/x/tools/internal/typesinternal#%s", target, code.String())
171172
}
172173

173174
func suggestedAnalysisFixes(snapshot *snapshot, pkg *pkg, diag *analysis.Diagnostic) ([]source.SuggestedFix, error) {

0 commit comments

Comments
 (0)