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:
parent
8bdde6d5f2
commit
a754db16a4
|
@ -67,6 +67,9 @@ func (d *definition) Run(ctx context.Context, args ...string) error {
|
||||||
}
|
}
|
||||||
tok := f.GetToken()
|
tok := f.GetToken()
|
||||||
pos := tok.Pos(from.Start.Offset)
|
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)
|
ident, err := source.Identifier(ctx, view, f, pos)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -7,6 +7,7 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/token"
|
"go/token"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -98,6 +99,9 @@ func parseLocation(value string) (Location, error) {
|
||||||
return loc, fmt.Errorf("bad location syntax %q", value)
|
return loc, fmt.Errorf("bad location syntax %q", value)
|
||||||
}
|
}
|
||||||
loc.Filename = m[posReFile]
|
loc.Filename = m[posReFile]
|
||||||
|
if !filepath.IsAbs(loc.Filename) {
|
||||||
|
loc.Filename, _ = filepath.Abs(loc.Filename) // ignore error
|
||||||
|
}
|
||||||
if m[posReSLine] != "" {
|
if m[posReSLine] != "" {
|
||||||
v, err := strconv.ParseInt(m[posReSLine], 10, 32)
|
v, err := strconv.ParseInt(m[posReSLine], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue