mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
internal/lsp: fix accepting line:colum forms to query definition
Change-Id: I425a9ebf77925b16fb7cb6fd5727d2377ab836b1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/168178 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
a41300a290
commit
bb1270c20e
@ -67,12 +67,12 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tok := f.GetToken(ctx)
|
||||
pos := tok.Pos(from.Start().Offset())
|
||||
if !pos.IsValid() {
|
||||
return fmt.Errorf("invalid position %v", from)
|
||||
converter := span.NewTokenConverter(view.FileSet(), f.GetToken(ctx))
|
||||
rng, err := from.Range(converter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ident, err := source.Identifier(ctx, view, f, pos)
|
||||
ident, err := source.Identifier(ctx, view, f, rng.Start)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%v: %v", from, err)
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ func TestDefinitionHelpExample(t *testing.T) {
|
||||
thisFile := filepath.Join(dir, "definition.go")
|
||||
baseArgs := []string{"query", "definition"}
|
||||
expect := regexp.MustCompile(`^[\w/\\:_]+flag[/\\]flag.go:\d+:\d+-\d+: defined here as type flag.FlagSet struct{.*}$`)
|
||||
for _, query := range []string{fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
|
||||
for _, query := range []string{
|
||||
fmt.Sprintf("%v:%v:%v", thisFile, cmd.ExampleLine, cmd.ExampleColumn),
|
||||
fmt.Sprintf("%v:#%v", thisFile, cmd.ExampleOffset)} {
|
||||
args := append(baseArgs, query)
|
||||
got := captureStdOut(t, func() {
|
||||
tool.Main(context.Background(), &cmd.Application{}, args)
|
||||
|
Loading…
Reference in New Issue
Block a user