-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version)?
$ go version go version go1.20.2 linux/arm64 $ go list -m golang.org/x/tools golang.org/x/tools v0.8.1-0.20230424202313-71ea8f168c16 $ go list -m golang.org/x/tools/gopls golang.org/x/tools/gopls v0.0.0-20230424202313-71ea8f168c16
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="on" GOARCH="arm64" GOBIN="" GOCACHE="/home/myitcv/.cache/go-build" GOENV="/home/myitcv/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/myitcv/gostuff/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/myitcv/gostuff" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/myitcv/gos" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_arm64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build235298812=/tmp/go-build -gno-record-gcc-switches"
What did you do?
cd $(mktemp -d)
git clone https://github.com/mvdan/sh
cd sh
git checkout 1e9de6acbbb76e4387751bda2bba2cbd42a0ee5d
vi syntax/parser.go
Then perform a symbol search for rune, in an attempt to locate the symbol mvdan.cc/sh/v3/syntax.Parser.rune.
The results are ordered as follows (best match first):
mvdan.cc/sh/v3/interp.Runner
mvdan.cc/sh/v3/interp.runnerOpts
mvdan.cc/sh/v3/interp.RunnerOption
mvdan.cc/sh/v3/interp_test.runTest
mvdan.cc/sh/v3/interp_test.runTests
mvdan.cc/sh/v3/interp_test.runnerCtx
mvdan.cc/sh/v3/cmd/gosh.runInteractive
mvdan.cc/sh/v3/interp_test.runTestsUnix
mvdan.cc/sh/v3/interp_test.runTests64bit
mvdan.cc/sh/v3/interp_test.runTestsWindows
mvdan.cc/sh/v3/syntax.Parser.rune
mvdan.cc/sh/v3/syntax.singleRuneParam
mvdan.cc/sh/v3/interp_test.TestRunnerDir
...
I've included ~20% of the results returned. Notice that I performed this search when in the context of the syntax package.
The one row (in the first 20% of results) where there is a full match on the last element (i.e. the symbol itself), the row I actually want, is at position 11. There are less good matches in the first 10 rows, some of which are in test packages. None of those first 10 are in the package of interest (given the current file cursor position in syntax/parser.go).
This problem is related to #37237. That said, #37236 (comment) makes clear that there are currently no plans to implement such an approach.
Therefore I think the current matching logic should be better here.
I've not looked at this part of the code recently, but it seems like the scoring of perfect matches for the symbol itself could/should score much higher?
What did you expect to see?
mvdan.cc/sh/v3/syntax.Parser.rune returned as the first result.
What did you see instead?
As above.