-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gopls-release-branch.0.16] gopls/internal/golang: strip @v1.2.3 suff…
…ix from pkgdoc URLs The package path in a /pkg URL does not want a module version suffix: the view specifies the versions of all packages. Remove them. Fixes golang/go#68116 Change-Id: Icbe7a6e7346d12456724d005fe8f755872657055 Reviewed-on: https://go-review.googlesource.com/c/tools/+/594556 LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> (cherry picked from commit 1e6c1e2) Reviewed-on: https://go-review.googlesource.com/c/tools/+/595563 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,3 +553,53 @@ func main() { | |
}) | ||
} | ||
} | ||
|
||
func TestHoverInternalLinksIssue68116(t *testing.T) { | ||
// Links for the internal viewer should not include a module version suffix: | ||
// the package path and the view are an unambiguous key; see #68116. | ||
|
||
const proxy = ` | ||
-- [email protected]/go.mod -- | ||
module example.com | ||
go 1.12 | ||
-- [email protected]/a/a.go -- | ||
package a | ||
// F is a function. | ||
func F() | ||
` | ||
|
||
const mod = ` | ||
-- go.mod -- | ||
module main | ||
go 1.12 | ||
require example.com v1.2.3 | ||
-- main.go -- | ||
package main | ||
import "example.com/a" | ||
func main() { | ||
a.F() | ||
} | ||
` | ||
WithOptions( | ||
ProxyFiles(proxy), | ||
Settings{"linksInHover": "gopls"}, | ||
WriteGoSum("."), | ||
).Run(t, mod, func(t *testing.T, env *Env) { | ||
env.OpenFile("main.go") | ||
got, _ := env.Hover(env.RegexpSearch("main.go", "F")) | ||
const wantRE = "\\[`a.F` in gopls doc viewer\\]\\(http://127.0.0.1:[0-9]+/gopls/[^/]+/pkg/example.com\\?view=[0-9]+#F\\)" // no version | ||
if m, err := regexp.MatchString(wantRE, got.Value); err != nil { | ||
t.Fatalf("bad regexp in test: %v", err) | ||
} else if !m { | ||
t.Fatalf("hover output does not match %q; got:\n\n%s", wantRE, got.Value) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters