Open myitcv opened 1 year ago
Thanks. That's definitely not right. The scoring algorithm is simple: (1) cue should score higher than Continue, (2) shorter results should score higher than longer.
Reproduces with: gopls workspace_symbol -matcher=fastfuzzy "cue.str"
I'll investigate and fix for v0.14.0.
This isn't a bug in the scoring algorithm, per se: the fuzzy score of "cue.Str"
is indeed higher than all others.
But "cue.Str"
is down-ranked because it is outside of the workspace -- I didn't realize this initially because it is in a cue package, but of the main cue repo.
The following specific steps mitigate the problem (but see below -- these steps are too strict):
go work init && go work use -r .
Then both cue and cuelang.org will be considered "in the workspace", and results will match expectation.
But this is confusing for LSP clients without a strong concept of 'workspace folder'. We typically expand the workspace to all main modules (including any specified in go.work). It should be sufficient simply to use a go.work file, and open gopls from any directory.
It may also seem tempting to remove this down-ranking of non-workspace packages, but we have heard multiple times that some users don't want any non-workspace results. I think properly respecting go.work
files in symbol results is the way to resolve this problem.
I think properly respecting
go.work
files in symbol results is the way to resolve this problem.
Just so that I'm clear, are you suggesting I should add the cuelang.org/go
dependency to my go.work
file just so that symbol results in that dependency are not downranked?
If so, I don't think this is a solution in this case or in general. Because cuelang.org/go
is just one dependency of many, and I don't see myself creating go.work
files for this purpose.
If this downranking is the reason for the "bad" results (from my perspective), then I believe https://github.com/golang/go/issues/37237 is the better solution. Because with that approach, no such downranking would be required: I would explicitly be in a mode of searching the current package, the main module, workspace etc.
Just so that I'm clear, are you suggesting I should add the cuelang.org/go dependency to my go.work file just so that symbol results in that dependency are not downranked?
I'm not suggesting any action -- I'm simply explaining the current ranking :), and the heuristics behind it.
A go.work
is how we ask users to specify the code they are "working" on, and symbol search down ranks results outside of the workspace. I think the current behavior is incorrect in that the user needs to also think about the "workspace folder" -- as much as possible we want to eliminate this from the configuration space (see also #57979).
Yes, #37237 would address this for clients that integrate the new syntax or custom command.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Open vim/editor, and do a symbol search for
cue.Str
What did you expect to see?
The result for
cuelang.org/go/cue.Str
as the best match.What did you see instead?
cuelang.org/go/cue.Str
as the 13th best match with a number of worse matches scoring higher (highest score first)Logs from my session locally:
cc @findleyr