1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:14:46 -07:00

internal/lsp: absolutize paths when converting filenames to URIs

Fixes golang/go#30280

Change-Id: I95e72c8d952ce7d64114772e9ef3df6568ae5dd4
Reviewed-on: https://go-review.googlesource.com/c/163160
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-02-20 15:14:33 -05:00
parent 8bdde6d5f2
commit a754db16a4
2 changed files with 7 additions and 0 deletions

View File

@ -67,6 +67,9 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
}
tok := f.GetToken()
pos := tok.Pos(from.Start.Offset)
if !pos.IsValid() {
return fmt.Errorf("invalid position %v", from.Start.Offset)
}
ident, err := source.Identifier(ctx, view, f, pos)
if err != nil {
return err

View File

@ -7,6 +7,7 @@ package cmd
import (
"fmt"
"go/token"
"path/filepath"
"regexp"
"strconv"
@ -98,6 +99,9 @@ func parseLocation(value string) (Location, error) {
return loc, fmt.Errorf("bad location syntax %q", value)
}
loc.Filename = m[posReFile]
if !filepath.IsAbs(loc.Filename) {
loc.Filename, _ = filepath.Abs(loc.Filename) // ignore error
}
if m[posReSLine] != "" {
v, err := strconv.ParseInt(m[posReSLine], 10, 32)
if err != nil {